From 69dc4fd59494b1aa7de21e65f6f8d041ddd98bc0 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:53:11 -0300 Subject: [PATCH] Decor: Fix avatar decorations not showing This reverts & edits commit 3b295e1f6f7321cf7510547fa4c95dd61ff539be. --- src/plugins/consoleJanitor/index.ts | 28 +++++++++++++++++++ .../decor/lib/stores/AuthorizationStore.tsx | 2 +- src/webpack/common/utils.ts | 10 +++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/plugins/consoleJanitor/index.ts b/src/plugins/consoleJanitor/index.ts index 2c29bf670..4c5499cf4 100644 --- a/src/plugins/consoleJanitor/index.ts +++ b/src/plugins/consoleJanitor/index.ts @@ -130,6 +130,34 @@ export default definePlugin({ replace: "" } }, + // Zustand section + { + find: "[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.", + replacement: [ + { + match: /&&console\.warn\("\[DEPRECATED\] Passing a vanilla store will be unsupported in a future version\. Instead use `import { useStore } from 'zustand'`\."\)/, + replace: "" + }, + { + match: /console\.warn\("\[DEPRECATED\] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`\. They can be imported from 'zustand\/traditional'\. https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1937"\),/, + replace: "" + } + ] + }, + { + find: "[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead.", + replacement: { + match: /console\.warn\("\[DEPRECATED\] `getStorage`, `serialize` and `deserialize` options are deprecated\. Use `storage` option instead\."\),/, + replace: "" + } + }, + { + find: "[DEPRECATED] `context` will be removed in a future version. Instead use `import { createStore, useStore } from 'zustand'`. See: https://github.com/pmndrs/zustand/discussions/1180.", + replacement: { + match: /console\.warn\("\[DEPRECATED\] `context` will be removed in a future version\. Instead use `import { createStore, useStore } from 'zustand'`\. See: https:\/\/github\.com\/pmndrs\/zustand\/discussions\/1180\."\);/, + replace: "" + } + }, // Patches discords generic logger function { find: "Σ:", diff --git a/src/plugins/decor/lib/stores/AuthorizationStore.tsx b/src/plugins/decor/lib/stores/AuthorizationStore.tsx index ba71da99e..7f3468fd0 100644 --- a/src/plugins/decor/lib/stores/AuthorizationStore.tsx +++ b/src/plugins/decor/lib/stores/AuthorizationStore.tsx @@ -93,7 +93,7 @@ export const useAuthorizationStore = proxyLazy(() => zustandCreate( } as AuthorizationState), { name: "decor-auth", - getStorage: () => indexedDBStorage, + storage: indexedDBStorage, partialize: state => ({ tokens: state.tokens }), onRehydrateStorage: () => state => state?.init() } diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index 3f44d106d..4b1959b5a 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -163,9 +163,13 @@ waitFor(["open", "saveAccountChanges"], m => SettingsRouter = m); export const PermissionsBits: t.PermissionsBits = findLazy(m => typeof m.ADMINISTRATOR === "bigint"); -export const zustandCreate = findByCodeLazy("will be removed in v4"); +export const { zustandCreate } = mapMangledModuleLazy(["useSyncExternalStoreWithSelector:", "Object.assign", /(\i)\?(\i)\(\1\):\2/], { + zustandCreate: filters.byCode(/(\i)\?(\i)\(\1\):\2/) +}); -export const zustandPersist = findByCodeLazy("[zustand persist middleware]"); +export const { zustandPersist } = mapMangledModuleLazy(".onRehydrateStorage)?", { + zustandPersist: filters.byCode(/(\(\i,\i\))=>.+?\i\1/) +}); export const MessageActions = findByPropsLazy("editMessage", "sendMessage"); export const MessageCache = findByPropsLazy("clearCache", "_channelMessages"); @@ -181,7 +185,7 @@ export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLa toggleExpressionPicker: filters.byCode(/getState\(\)\.activeView===\i\?\i\(\):\i\(/), setExpressionPickerView: filters.byCode(/setState\({activeView:\i,lastActiveView:/), setSearchQuery: filters.byCode("searchQuery:"), - useExpressionPickerStore: filters.byCode("Object.is") + useExpressionPickerStore: filters.byCode(/\(\i,\i=\i\)=>/) }); export const PopoutActions: t.PopoutActions = mapMangledModuleLazy('type:"POPOUT_WINDOW_OPEN"', {