Decor: Fix crashing
This commit is contained in:
parent
2270b88a98
commit
cd3a998c4b
|
@ -130,6 +130,52 @@ export default definePlugin({
|
||||||
replace: ""
|
replace: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// Zustand section
|
||||||
|
{
|
||||||
|
find: "[DEPRECATED] Default export is deprecated. Instead use `import { create } from 'zustand'",
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
match: /console\.warn\("\[DEPRECATED\] Default export is deprecated\. Instead use `import { create } from 'zustand'`\."\),/,
|
||||||
|
replace: ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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] Default export is deprecated. Instead use import { createStore } from 'zustand/vanilla'.",
|
||||||
|
replacement: {
|
||||||
|
match: /console\.warn\("\[DEPRECATED\] Default export is deprecated\. Instead use import { createStore } from 'zustand\/vanilla'\."\),/,
|
||||||
|
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: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "[DEPRECATED] Default export is deprecated. Instead use `import { shallow } from 'zustand/shallow'`.",
|
||||||
|
replacement: {
|
||||||
|
match: /console\.warn\("\[DEPRECATED\] Default export is deprecated\. Instead use `import { shallow } from 'zustand\/shallow'`\."\),/,
|
||||||
|
replace: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
// Patches discords generic logger function
|
// Patches discords generic logger function
|
||||||
{
|
{
|
||||||
find: "Σ:",
|
find: "Σ:",
|
||||||
|
@ -147,5 +193,5 @@ export default definePlugin({
|
||||||
replace: "$self.NoopLogger()"
|
replace: "$self.NoopLogger()"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -93,7 +93,7 @@ export const useAuthorizationStore = proxyLazy(() => zustandCreate(
|
||||||
} as AuthorizationState),
|
} as AuthorizationState),
|
||||||
{
|
{
|
||||||
name: "decor-auth",
|
name: "decor-auth",
|
||||||
getStorage: () => indexedDBStorage,
|
storage: indexedDBStorage,
|
||||||
partialize: state => ({ tokens: state.tokens }),
|
partialize: state => ({ tokens: state.tokens }),
|
||||||
onRehydrateStorage: () => state => state?.init()
|
onRehydrateStorage: () => state => state?.init()
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import { getIntlMessage } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher, Menu, MessageStore, Parser, SelectedChannelStore, Timestamp, UserStore, useStateFromStores } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher, Menu, MessageStore, Parser, SelectedChannelStore, Timestamp, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
import { Message } from "discord-types/general";
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ interface MLMessage extends Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
||||||
const getMessage = findByCodeLazy('replace(/^\\n+|\\n+$/g,"")');
|
|
||||||
|
|
||||||
function addDeleteStyle() {
|
function addDeleteStyle() {
|
||||||
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
if (Settings.plugins.MessageLogger.deleteStyle === "text") {
|
||||||
|
@ -312,9 +311,8 @@ export default definePlugin({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
Messages: {
|
|
||||||
// DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}")
|
// DELETED_MESSAGE_COUNT: getMessage("{count, plural, =0 {No deleted messages} one {{count} deleted message} other {{count} deleted messages}}")
|
||||||
// TODO: find a better way to generate intl messages
|
// TODO: Find a better way to generate intl messages
|
||||||
DELETED_MESSAGE_COUNT: () => ({
|
DELETED_MESSAGE_COUNT: () => ({
|
||||||
ast: [[
|
ast: [[
|
||||||
6,
|
6,
|
||||||
|
@ -339,8 +337,7 @@ export default definePlugin({
|
||||||
0,
|
0,
|
||||||
"cardinal"
|
"cardinal"
|
||||||
]]
|
]]
|
||||||
})
|
}),
|
||||||
},
|
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
|
@ -531,7 +528,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?.*?:/,
|
match: /(\i).type===\i\.\i\.MESSAGE_GROUP_BLOCKED\?.*?:/,
|
||||||
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.Messages.DELETED_MESSAGE_COUNT:',
|
replace: '$&$1.type==="MESSAGE_GROUP_DELETED"?$self.DELETED_MESSAGE_COUNT:',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
predicate: () => Settings.plugins.MessageLogger.collapseDeleted
|
predicate: () => Settings.plugins.MessageLogger.collapseDeleted
|
||||||
|
|
|
@ -28,8 +28,8 @@ import { Message } from "discord-types/general";
|
||||||
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
||||||
|
|
||||||
interface MessageDeleteProps {
|
interface MessageDeleteProps {
|
||||||
// i18n message i18n.t["+FcYMz"] if deleted, with args
|
// Internal intl message for BLOCKED_MESSAGE_COUNT
|
||||||
collapsedReason: () => any
|
collapsedReason: () => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
|
|
|
@ -163,9 +163,13 @@ waitFor(["open", "saveAccountChanges"], m => SettingsRouter = m);
|
||||||
|
|
||||||
export const PermissionsBits: t.PermissionsBits = findLazy(m => typeof m.ADMINISTRATOR === "bigint");
|
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"], {
|
||||||
|
zustandCreate: m => typeof m === "function"
|
||||||
|
});
|
||||||
|
|
||||||
export const zustandPersist = findByCodeLazy("[zustand persist middleware]");
|
export const { zustandPersist } = mapMangledModuleLazy(".onRehydrateStorage)?", {
|
||||||
|
zustandPersist: m => typeof m === "function"
|
||||||
|
});
|
||||||
|
|
||||||
export const MessageActions = findByPropsLazy("editMessage", "sendMessage");
|
export const MessageActions = findByPropsLazy("editMessage", "sendMessage");
|
||||||
export const MessageCache = findByPropsLazy("clearCache", "_channelMessages");
|
export const MessageCache = findByPropsLazy("clearCache", "_channelMessages");
|
||||||
|
@ -181,7 +185,7 @@ export const ExpressionPickerStore: t.ExpressionPickerStore = mapMangledModuleLa
|
||||||
toggleExpressionPicker: filters.byCode(/getState\(\)\.activeView===\i\?\i\(\):\i\(/),
|
toggleExpressionPicker: filters.byCode(/getState\(\)\.activeView===\i\?\i\(\):\i\(/),
|
||||||
setExpressionPickerView: filters.byCode(/setState\({activeView:\i,lastActiveView:/),
|
setExpressionPickerView: filters.byCode(/setState\({activeView:\i,lastActiveView:/),
|
||||||
setSearchQuery: filters.byCode("searchQuery:"),
|
setSearchQuery: filters.byCode("searchQuery:"),
|
||||||
useExpressionPickerStore: filters.byCode("Object.is")
|
useExpressionPickerStore: filters.byCode(".getInitialState")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PopoutActions: t.PopoutActions = mapMangledModuleLazy('type:"POPOUT_WINDOW_OPEN"', {
|
export const PopoutActions: t.PopoutActions = mapMangledModuleLazy('type:"POPOUT_WINDOW_OPEN"', {
|
||||||
|
|
Loading…
Reference in a new issue