From 03d7e0fb93a32c2ee6984cfdb7e2d5ea3f4de127 Mon Sep 17 00:00:00 2001 From: dolfies Date: Fri, 3 May 2024 09:09:54 -0400 Subject: [PATCH 1/5] fix sort conflict of ImplicitRelationships & SortFriendRequests (#2408) --- src/plugins/implicitRelationships/index.ts | 8 ++++---- src/plugins/sortFriendRequests/index.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index be17e0fe4..15165d64a 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -81,8 +81,8 @@ export default definePlugin({ find: "getRelationshipCounts(){", replacement: { predicate: () => Settings.plugins.ImplicitRelationships.sortByAffinity, - match: /\.sortBy\(\i=>\i\.comparator\)/, - replace: "$&.sortBy((row) => $self.sortList(row))" + match: /\}\)\.sortBy\((.+?)\)\.value\(\)/, + replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()" } }, @@ -120,10 +120,10 @@ export default definePlugin({ } ), - sortList(row: any) { + wrapSort(comparator: Function, row: any) { return row.type === 5 ? -UserAffinitiesStore.getUserAffinity(row.user.id)?.affinity ?? 0 - : row.comparator; + : comparator(row); }, async fetchImplicitRelationships() { diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index 32579a803..7033591bd 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -41,8 +41,8 @@ export default definePlugin({ patches: [{ find: "getRelationshipCounts(){", replacement: { - match: /\.sortBy\(\i=>\i\.comparator\)/, - replace: "$&.sortBy((row) => $self.sortList(row))" + match: /\}\)\.sortBy\((.+?)\)\.value\(\)/, + replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()" } }, { find: ".Messages.FRIEND_REQUEST_CANCEL", @@ -53,10 +53,10 @@ export default definePlugin({ } }], - sortList(row: any) { + wrapSort(comparator: Function, row: any) { return row.type === 3 || row.type === 4 ? -this.getSince(row.user) - : row.comparator; + : comparator(row); }, getSince(user: User) { From 315f4f4e587f1d15f69b94c0d1b89b42f43c5eaf Mon Sep 17 00:00:00 2001 From: Sqaaakoi Date: Sat, 4 May 2024 01:17:12 +1200 Subject: [PATCH 2/5] ReviewDB: add more context menu shortcuts to view reviews (#2382) Co-authored-by: V --- src/plugins/reviewDB/index.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 0c3578b07..bcd0f163f 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -35,13 +35,25 @@ import { getCurrentUserInfo, readNotification } from "./reviewDbApi"; import { settings } from "./settings"; import { showToast } from "./utils"; -const guildPopoutPatch: NavContextMenuPatchCallback = (children, props: { guild: Guild, onClose(): void; }) => { +const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => { children.push( openReviewsModal(props.guild.id, props.guild.name)} + action={() => openReviewsModal(guild.id, guild.name)} + /> + ); +}; + +const userContextPatch: NavContextMenuPatchCallback = (children, { user }: { user?: User, onClose(): void; }) => { + if (!user) return; + children.push( + openReviewsModal(user.id, user.username)} /> ); }; @@ -53,7 +65,10 @@ export default definePlugin({ settings, contextMenus: { - "guild-header-popout": guildPopoutPatch + "guild-header-popout": guildPopoutPatch, + "guild-context": guildPopoutPatch, + "user-context": userContextPatch, + "user-profile-actions": userContextPatch }, patches: [ From 1af44b25f3fa3c6be7ddf66eea82c1adbc087a5a Mon Sep 17 00:00:00 2001 From: katlyn <17418611+katlyn@users.noreply.github.com> Date: Fri, 3 May 2024 06:51:53 -0800 Subject: [PATCH 3/5] feat(USRBG): update to new API (#2388) --- src/plugins/usrbg/index.tsx | 41 +++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index ce6bd709b..b92839a9a 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -24,9 +24,14 @@ import definePlugin, { OptionType } from "@utils/types"; import style from "./index.css?managed"; -const BASE_URL = "https://raw.githubusercontent.com/AutumnVN/usrbg/main/usrbg.json"; +const API_URL = "https://usrbg.is-hardly.online/users"; -let data = {} as Record; +interface UsrbgApiReturn { + endpoint: string + bucket: string + prefix: string + users: Record +} const settings = definePluginSettings({ nitroFirst: { @@ -48,7 +53,7 @@ const settings = definePluginSettings({ export default definePlugin({ name: "USRBG", description: "Displays user banners from USRBG, allowing anyone to get a banner without Nitro", - authors: [Devs.AutumnVN, Devs.pylix, Devs.TheKodeToad], + authors: [Devs.AutumnVN, Devs.katlyn, Devs.pylix, Devs.TheKodeToad], settings, patches: [ { @@ -80,8 +85,7 @@ export default definePlugin({ } ], - - data, + data: null as UsrbgApiReturn | null, settingsAboutComponent: () => { return ( @@ -91,9 +95,9 @@ export default definePlugin({ voiceBackgroundHook({ className, participantUserId }: any) { if (className.includes("tile_")) { - if (data[participantUserId]) { + if (this.userHasBackground(participantUserId)) { return { - backgroundImage: `url(${data[participantUserId]})`, + backgroundImage: `url(${this.getImageUrl(participantUserId)})`, backgroundSize: "cover", backgroundPosition: "center", backgroundRepeat: "no-repeat" @@ -104,24 +108,35 @@ export default definePlugin({ useBannerHook({ displayProfile, user }: any) { if (displayProfile?.banner && settings.store.nitroFirst) return; - if (data[user.id]) return data[user.id]; + if (this.userHasBackground(user.id)) return this.getImageUrl(user.id); }, premiumHook({ userId }: any) { - if (data[userId]) return 2; + if (this.userHasBackground(userId)) return 2; }, shouldShowBadge({ displayProfile, user }: any) { - return displayProfile?.banner && (!data[user.id] || settings.store.nitroFirst); + return displayProfile?.banner && (!this.userHasBackground(user.id) || settings.store.nitroFirst); + }, + + userHasBackground(userId: string) { + return !!this.data?.users[userId]; + }, + + getImageUrl(userId: string): string|null { + if (!this.userHasBackground(userId)) return null; + + // We can assert that data exists because userHasBackground returned true + const { endpoint, bucket, prefix, users: { [userId]: etag } } = this.data!; + return `${endpoint}/${bucket}/${prefix}${userId}?${etag}`; }, async start() { enableStyle(style); - const res = await fetch(BASE_URL); + const res = await fetch(API_URL); if (res.ok) { - data = await res.json(); - this.data = data; + this.data = await res.json(); } } }); From 78183eb226c360dbdd978c32ea08ccc9ac38f475 Mon Sep 17 00:00:00 2001 From: sunnie <78964224+sunnniee@users.noreply.github.com> Date: Fri, 3 May 2024 23:00:42 +0300 Subject: [PATCH 4/5] MsgClickActions: control ping via shift & NoReplyMention plugin (#2390) Co-authored-by: V --- src/plugins/messageClickActions/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/messageClickActions/index.ts b/src/plugins/messageClickActions/index.ts index 3d4bb21bb..14899c367 100644 --- a/src/plugins/messageClickActions/index.ts +++ b/src/plugins/messageClickActions/index.ts @@ -17,7 +17,7 @@ */ import { addClickListener, removeClickListener } from "@api/MessageEvents"; -import { definePluginSettings, Settings } from "@api/Settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByPropsLazy } from "@webpack"; @@ -84,11 +84,17 @@ export default definePlugin({ const EPHEMERAL = 64; if (msg.hasFlag(EPHEMERAL)) return; + const isShiftPress = event.shiftKey && !settings.store.requireModifier; + const NoReplyMention = Vencord.Plugins.plugins.NoReplyMention as any as typeof import("../noReplyMention").default; + const shouldMention = Vencord.Plugins.isPluginEnabled("NoReplyMention") + ? NoReplyMention.shouldMention(msg, isShiftPress) + : !isShiftPress; + FluxDispatcher.dispatch({ type: "CREATE_PENDING_REPLY", channel, message: msg, - shouldMention: !Settings.plugins.NoReplyMention.enabled, + shouldMention, showMentionToggle: channel.guild_id !== null }); } From 520e9151681db577007ab8a5b6a1ecb5b9aae7b8 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 3 May 2024 22:18:31 +0200 Subject: [PATCH 5/5] fix badges with custom component --- src/plugins/_api/badges.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/_api/badges.tsx b/src/plugins/_api/badges.tsx index 6cbe1feb0..3cfbb4d99 100644 --- a/src/plugins/_api/badges.tsx +++ b/src/plugins/_api/badges.tsx @@ -78,7 +78,7 @@ export default definePlugin({ }, // replace their component with ours if applicable { - match: /(?<=text:(\i)\.description,spacing:12,)children:/, + match: /(?<=text:(\i)\.description,spacing:12,.{0,50})children:/, replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :" }, // conditionally override their onClick with badge.onClick if it exists