Compare commits

..

No commits in common. "27ab83c179388ee36acb912db6e35f08eb93a863" and "14367d7cc8da6cb0e216baf587b82e00aadc1bdb" have entirely different histories.

4 changed files with 17 additions and 35 deletions

View file

@ -73,17 +73,19 @@ export default definePlugin({
find: ".description,delay:", find: ".description,delay:",
replacement: [ replacement: [
{ {
match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/, // alt: "", aria-hidden: false, src: originalSrc
replace: (_, rest, originalSrc, badge) => `...${badge}.props,${rest}${badge}.image??(${originalSrc})` match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/,
// ...badge.props, ..., src: badge.image ?? ...
replace: "...$1.props,$& $1.image??"
}, },
{ {
match: /(?<="aria-label":(\i)\.description,.{0,200})children:/, match: /(?<="aria-label":(\i)\.description,.{0,200})children:/,
replace: "children:$1.component?$self.renderBadgeComponent({...$1}) :" replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
}, },
// conditionally override their onClick with badge.onClick if it exists // conditionally override their onClick with badge.onClick if it exists
{ {
match: /href:(\i)\.link/, match: /href:(\i)\.link/,
replace: "...($1.onClick&&{onClick:vcE=>$1.onClick(vcE,$1)}),$&" replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
} }
] ]
} }

View file

@ -153,7 +153,13 @@ function makeShortcuts() {
openModal: { getter: () => ModalAPI.openModal }, openModal: { getter: () => ModalAPI.openModal },
openModalLazy: { getter: () => ModalAPI.openModalLazy }, openModalLazy: { getter: () => ModalAPI.openModalLazy },
Stores: Webpack.fluxStores Stores: {
getter: () => Object.fromEntries(
Common.Flux.Store.getAll()
.map(store => [store.getName(), store] as const)
.filter(([name]) => name.length > 1)
)
}
}; };
} }

View file

@ -173,15 +173,6 @@ export default definePlugin({
} catch (err) { } catch (err) {
CrashHandlerLogger.debug("Failed to pop all layers.", err); CrashHandlerLogger.debug("Failed to pop all layers.", err);
} }
try {
FluxDispatcher.dispatch({
type: "DEV_TOOLS_SETTINGS_UPDATE",
settings: { displayTools: false, lastOpenTabId: "analytics" }
});
} catch (err) {
CrashHandlerLogger.debug("Failed to close DevTools.", err);
}
if (settings.store.attemptToNavigateToHome) { if (settings.store.attemptToNavigateToHome) {
try { try {
NavigationRouter.transitionToGuild("@me"); NavigationRouter.transitionToGuild("@me");
@ -190,6 +181,7 @@ export default definePlugin({
} }
} }
// Set isRecovering to false before setting the state to allow us to handle the next crash error correcty, in case it happens // Set isRecovering to false before setting the state to allow us to handle the next crash error correcty, in case it happens
setImmediate(() => isRecovering = false); setImmediate(() => isRecovering = false);

View file

@ -20,7 +20,6 @@ import { makeLazy, proxyLazy } from "@utils/lazy";
import { LazyComponent } from "@utils/lazyReact"; import { LazyComponent } from "@utils/lazyReact";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { canonicalizeMatch } from "@utils/patches"; import { canonicalizeMatch } from "@utils/patches";
import { FluxStore } from "@webpack/types";
import { traceFunction } from "../debug/Tracer"; import { traceFunction } from "../debug/Tracer";
import { Flux } from "./common"; import { Flux } from "./common";
@ -38,8 +37,6 @@ export const onceReady = new Promise<void>(r => _resolveReady = r);
export let wreq: WebpackRequire; export let wreq: WebpackRequire;
export let cache: WebpackRequire["c"]; export let cache: WebpackRequire["c"];
export const fluxStores: Record<string, FluxStore> = {};
export type FilterFn = (mod: any) => boolean; export type FilterFn = (mod: any) => boolean;
export type PropsFilter = Array<string>; export type PropsFilter = Array<string>;
@ -431,24 +428,9 @@ export function findByCodeLazy(...code: CodeFilter) {
* Find a store by its displayName * Find a store by its displayName
*/ */
export function findStore(name: StoreNameFilter) { export function findStore(name: StoreNameFilter) {
let res = fluxStores[name] as any; const res = Flux.Store.getAll
if (res == null) { ? Flux.Store.getAll().find(filters.byStoreName(name))
for (const store of Flux.Store.getAll?.() ?? []) { : find(filters.byStoreName(name), { isIndirect: true });
const storeName = store.getName();
if (storeName === name) {
res = store;
}
if (fluxStores[storeName] == null) {
fluxStores[storeName] = store;
}
}
if (res == null) {
res = find(filters.byStoreName(name), { isIndirect: true });
}
}
if (!res) if (!res)
handleModuleNotFound("findStore", name); handleModuleNotFound("findStore", name);