fix FriendsSince on canary

main
Vendicated 5 months ago
parent 74df53e7c8
commit 0bebc85b0d
No known key found for this signature in database
GPG Key ID: D66986BAF75ECF18

@ -7,12 +7,22 @@
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { getCurrentChannel } from "@utils/discord"; import { getCurrentChannel } from "@utils/discord";
import { makeLazy } from "@utils/lazy";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack"; import { filters, find, findByPropsLazy, handleModuleNotFound } from "@webpack";
import { React, RelationshipStore } from "@webpack/common"; import { React, RelationshipStore } from "@webpack/common";
const { Heading, Text } = findByPropsLazy("Heading", "Text"); const { Heading, Text } = findByPropsLazy("Heading", "Text");
const container = findByPropsLazy("memberSinceContainer"); // 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 { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate"); const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate");
const clydeMoreInfo = findByPropsLazy("clydeMoreInfo"); const clydeMoreInfo = findByPropsLazy("clydeMoreInfo");
const locale = findByPropsLazy("getLocale"); const locale = findByPropsLazy("getLocale");
@ -49,7 +59,7 @@ export default definePlugin({
Friends Since Friends Since
</Heading> </Heading>
<div className={container.memberSinceContainer}> <div className={getMemberSinceContainer()}>
{!!getCurrentChannel()?.guild_id && ( {!!getCurrentChannel()?.guild_id && (
<svg <svg
aria-hidden="true" aria-hidden="true"

@ -92,7 +92,7 @@ if (IS_DEV && IS_DISCORD_DESKTOP) {
}, 0); }, 0);
} }
function handleModuleNotFound(method: string, ...filter: unknown[]) { export function handleModuleNotFound(method: string, ...filter: unknown[]) {
const err = new Error(`webpack.${method} found no module`); const err = new Error(`webpack.${method} found no module`);
logger.error(err, "Filter:", filter); logger.error(err, "Filter:", filter);

Loading…
Cancel
Save