Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
verticalsync committed Apr 27, 2024
2 parents 350af62 + 5b15c19 commit f7ecde1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "suncord",
"private": "true",
"version": "1.8.3",
"version": "1.8.4",
"description": "A fork of the Discord client mod Vencord.",
"homepage": "https://github.com/verticalsync/Suncord#readme",
"bugs": {
Expand Down
16 changes: 3 additions & 13 deletions src/plugins/friendsSince/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { getCurrentChannel } from "@utils/discord";
import { makeLazy } from "@utils/lazy";
import definePlugin from "@utils/types";
import { filters, find, findByPropsLazy, handleModuleNotFound } from "@webpack";
import { findByPropsLazy } from "@webpack";
import { React, RelationshipStore } from "@webpack/common";

const { Heading, Text } = findByPropsLazy("Heading", "Text");
// Workaround for module differing on stable & canary
// FIXME: remove once merged into stable
const getMemberSinceContainer = makeLazy(() => {
for (const name of ["memberSinceWrapper", "memberSinceContainer"]) {
const mod = find(filters.byProps(name), { isIndirect: true });
if (mod) return mod[name];
}
handleModuleNotFound("findByProps", "memberSinceWrapper/memberSinceContainer");
return "";
});
const container = findByPropsLazy("memberSinceWrapper");
const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate");
const clydeMoreInfo = findByPropsLazy("clydeMoreInfo");
const locale = findByPropsLazy("getLocale");
Expand Down Expand Up @@ -59,7 +49,7 @@ export default definePlugin({
Friends Since
</Heading>

<div className={getMemberSinceContainer()}>
<div className={container.memberSinceWrapper}>
{!!getCurrentChannel()?.guild_id && (
<svg
aria-hidden="true"
Expand Down
25 changes: 15 additions & 10 deletions src/plugins/implicitRelationships/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,25 @@ export default definePlugin({
// OP 8 Request Guild Members allows 100 user IDs at a time
const ignore = new Set(toRequest);
const relationships = RelationshipStore.getRelationships();
const callback = ({ nonce, members }) => {
if (nonce !== sentNonce) return;
members.forEach(member => {
ignore.delete(member.user.id);
});
const callback = ({ chunks }) => {
for (const chunk of chunks) {
const { nonce, members } = chunk;
if (nonce !== sentNonce) return;
members.forEach(member => {
ignore.delete(member.user.id);
});

nonFriendAffinities.map(id => UserStore.getUser(id)).filter(user => user && !ignore.has(user.id)).forEach(user => relationships[user.id] = 5);
RelationshipStore.emitChange();
if (--count === 0) {
FluxDispatcher.unsubscribe("GUILD_MEMBERS_CHUNK", callback);
nonFriendAffinities.map(id => UserStore.getUser(id)).filter(user => user && !ignore.has(user.id)).forEach(user => relationships[user.id] = 5);
RelationshipStore.emitChange();
if (--count === 0) {
// @ts-ignore
FluxDispatcher.unsubscribe("GUILD_MEMBERS_CHUNK_BATCH", callback);
}
}
};

FluxDispatcher.subscribe("GUILD_MEMBERS_CHUNK", callback);
// @ts-ignore
FluxDispatcher.subscribe("GUILD_MEMBERS_CHUNK_BATCH", callback);
for (let i = 0; i < toRequest.length; i += 100) {
FluxDispatcher.dispatch({
type: "GUILD_MEMBERS_REQUEST",
Expand Down
12 changes: 7 additions & 5 deletions src/plugins/moreUserTags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ export default definePlugin({
replacement: [
// make the tag show the right text
{
match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=.{0,40}(\i\.\i\.Messages)\.BOT_TAG_BOT/,
// FIXME: Remove the BOT_TAG_BOT variant when the change arrives in stable
match: /(switch\((\i)\){.+?)case (\i(?:\.\i)?)\.BOT:default:(\i)=.{0,40}(\i\.\i\.Messages)\.(?:APP_TAG|BOT_TAG_BOT)/,
replace: (_, origSwitch, variant, tags, displayedText, strings) =>
`${origSwitch}default:{${displayedText} = $self.getTagText(${tags}[${variant}], ${strings})}`
},
Expand Down Expand Up @@ -321,19 +322,20 @@ export default definePlugin({

isOPTag: (tag: number) => tag === Tag.Types.ORIGINAL_POSTER || tags.some(t => tag === Tag.Types[`${t.name}-OP`]),

// FIXME: Remove the BOT_TAG_BOT variants from strings when the change arrives in stable
getTagText(passedTagName: string, strings: Record<string, string>) {
if (!passedTagName) return strings.BOT_TAG_BOT;
if (!passedTagName) return strings.APP_TAG ?? strings.BOT_TAG_BOT;
const [tagName, variant] = passedTagName.split("-");
const tag = tags.find(({ name }) => tagName === name);
if (!tag) return strings.BOT_TAG_BOT;
if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.BOT_TAG_BOT;
if (!tag) return strings.APP_TAG ?? strings.BOT_TAG_BOT;
if (variant === "BOT" && tagName !== "WEBHOOK" && this.settings.store.dontShowForBots) return strings.APP_TAG ?? strings.BOT_TAG_BOT;

const tagText = settings.store.tagSettings?.[tag.name]?.text || tag.displayName;
switch (variant) {
case "OP":
return `${strings.BOT_TAG_FORUM_ORIGINAL_POSTER}${tagText}`;
case "BOT":
return `${strings.BOT_TAG_BOT}${tagText}`;
return `${strings.APP_TAG ?? strings.BOT_TAG_BOT}${tagText}`;
default:
return tagText;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/pronoundb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default definePlugin({
find: ".pronouns,children",
replacement: [
{
match: /{user:(\i),[^}]*,pronouns:(\i),[^}]*}=\i;/,
match: /{user:(\i),[^}]*,pronouns:(\i),[^}]*}=\i.*?;(?=return)/,
replace: "$&let vcPronounSource;[$2,vcPronounSource]=$self.useProfilePronouns($1.id);"
},
PRONOUN_TOOLTIP_PATCH
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/roleColorEverywhere/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default definePlugin({
find: "renderPrioritySpeaker",
replacement: [
{
match: /renderName\(\).{0,100}speaking:.{50,200}"div",{/,
match: /renderName\(\).{0,100}speaking:.+?\.clanTag.+?"div",{/,
replace: "$&...$self.getVoiceProps(this.props),"
}
],
Expand Down

0 comments on commit f7ecde1

Please sign in to comment.