Merge branch 'main' of https://github.com/Vendicated/Vencord
This commit is contained in:
commit
27ab83c179
4 changed files with 35 additions and 17 deletions
|
@ -73,19 +73,17 @@ export default definePlugin({
|
|||
find: ".description,delay:",
|
||||
replacement: [
|
||||
{
|
||||
// alt: "", aria-hidden: false, src: originalSrc
|
||||
match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/,
|
||||
// ...badge.props, ..., src: badge.image ?? ...
|
||||
replace: "...$1.props,$& $1.image??"
|
||||
match: /(alt:" ","aria-hidden":!0,src:)(.{0,20}(\i)\.icon\))/,
|
||||
replace: (_, rest, originalSrc, badge) => `...${badge}.props,${rest}${badge}.image??(${originalSrc})`
|
||||
},
|
||||
{
|
||||
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
|
||||
{
|
||||
match: /href:(\i)\.link/,
|
||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
|
||||
replace: "...($1.onClick&&{onClick:vcE=>$1.onClick(vcE,$1)}),$&"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -153,13 +153,7 @@ function makeShortcuts() {
|
|||
openModal: { getter: () => ModalAPI.openModal },
|
||||
openModalLazy: { getter: () => ModalAPI.openModalLazy },
|
||||
|
||||
Stores: {
|
||||
getter: () => Object.fromEntries(
|
||||
Common.Flux.Store.getAll()
|
||||
.map(store => [store.getName(), store] as const)
|
||||
.filter(([name]) => name.length > 1)
|
||||
)
|
||||
}
|
||||
Stores: Webpack.fluxStores
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,15 @@ export default definePlugin({
|
|||
} catch (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) {
|
||||
try {
|
||||
NavigationRouter.transitionToGuild("@me");
|
||||
|
@ -181,7 +190,6 @@ 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
|
||||
setImmediate(() => isRecovering = false);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import { makeLazy, proxyLazy } from "@utils/lazy";
|
|||
import { LazyComponent } from "@utils/lazyReact";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { canonicalizeMatch } from "@utils/patches";
|
||||
import { FluxStore } from "@webpack/types";
|
||||
|
||||
import { traceFunction } from "../debug/Tracer";
|
||||
import { Flux } from "./common";
|
||||
|
@ -37,6 +38,8 @@ export const onceReady = new Promise<void>(r => _resolveReady = r);
|
|||
export let wreq: WebpackRequire;
|
||||
export let cache: WebpackRequire["c"];
|
||||
|
||||
export const fluxStores: Record<string, FluxStore> = {};
|
||||
|
||||
export type FilterFn = (mod: any) => boolean;
|
||||
|
||||
export type PropsFilter = Array<string>;
|
||||
|
@ -428,9 +431,24 @@ export function findByCodeLazy(...code: CodeFilter) {
|
|||
* Find a store by its displayName
|
||||
*/
|
||||
export function findStore(name: StoreNameFilter) {
|
||||
const res = Flux.Store.getAll
|
||||
? Flux.Store.getAll().find(filters.byStoreName(name))
|
||||
: find(filters.byStoreName(name), { isIndirect: true });
|
||||
let res = fluxStores[name] as any;
|
||||
if (res == null) {
|
||||
for (const store of Flux.Store.getAll?.() ?? []) {
|
||||
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)
|
||||
handleModuleNotFound("findStore", name);
|
||||
|
|
Loading…
Add table
Reference in a new issue