FakeProfileThemesAndEffects: Fix Effects Crashing
This commit is contained in:
parent
330788ed25
commit
125287c8c5
3 changed files with 26 additions and 19 deletions
|
|
@ -4,11 +4,11 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { useMemo } from "@webpack/common";
|
||||
import { showToast, Toasts, useMemo } from "@webpack/common";
|
||||
|
||||
import { Builder, type BuilderProps, setProfileEffectModal, settingsAboutComponent } from "./components";
|
||||
import { ProfileEffectRecord, ProfileEffectStore } from "./lib/profileEffects";
|
||||
|
|
@ -163,6 +163,12 @@ export default definePlugin({
|
|||
}
|
||||
],
|
||||
|
||||
start: () => {
|
||||
const { FakeProfileThemesAndEffects, FakeProfileThemes } = Settings.plugins;
|
||||
if (FakeProfileThemes.enabled && FakeProfileThemesAndEffects.enabled) FakeProfileThemes.enabled = false;
|
||||
showToast("Disabled FakeProfileThemes as FakeProfileThemesAndEffects is enabled", Toasts.Type.SUCCESS);
|
||||
},
|
||||
|
||||
addFPTEBuilder: (guild?: BuilderProps["guild"]) => settings.store.hideBuilder ? null : <Builder guild={guild} />,
|
||||
|
||||
onApply(_effectId?: string) { },
|
||||
|
|
@ -178,23 +184,24 @@ export default definePlugin({
|
|||
|
||||
ProfileEffectSelection: () => null,
|
||||
|
||||
usePurchases: () => useMemo(
|
||||
() => new Map(ProfileEffectStore.profileEffects.map(effect => [
|
||||
effect.id,
|
||||
{ items: new ProfileEffectRecord(effect) }
|
||||
])),
|
||||
[ProfileEffectStore.profileEffects]
|
||||
),
|
||||
usePurchases: () => useMemo(() => {
|
||||
return new Map(
|
||||
ProfileEffectStore.getAllProfileEffects().map(effect => [
|
||||
effect.id,
|
||||
{ items: new ProfileEffectRecord(effect) }
|
||||
])
|
||||
);
|
||||
}, [ProfileEffectStore.getAllProfileEffects()]),
|
||||
|
||||
useProfileEffectSections: (origSections: Record<string, any>[]) => useMemo(
|
||||
() => {
|
||||
origSections.splice(1);
|
||||
origSections[0].items.splice(1);
|
||||
for (const effect of ProfileEffectStore.profileEffects)
|
||||
for (const effect of ProfileEffectStore.getAllProfileEffects())
|
||||
origSections[0].items.push(new ProfileEffectRecord(effect));
|
||||
return origSections;
|
||||
},
|
||||
[ProfileEffectStore.profileEffects]
|
||||
[ProfileEffectStore.getAllProfileEffects()]
|
||||
),
|
||||
|
||||
settings,
|
||||
|
|
|
|||
|
|
@ -9,13 +9,10 @@ import { findByCodeLazy, findStoreLazy } from "@webpack";
|
|||
import type { SnakeCasedProperties } from "type-fest";
|
||||
|
||||
export const ProfileEffectStore: FluxStore & {
|
||||
canFetch: () => boolean;
|
||||
canFetchAll: () => boolean;
|
||||
getProfileEffectById: (effectId: string) => ProfileEffect | undefined;
|
||||
hasFetched: () => boolean;
|
||||
readonly fetchError: Error | undefined;
|
||||
readonly isFetching: boolean;
|
||||
readonly profileEffects: ProfileEffect[];
|
||||
readonly tryItOutId: string | null;
|
||||
isFetchingAll: () => boolean;
|
||||
getAllProfileEffects: () => ProfileEffect[];
|
||||
} = findStoreLazy("ProfileEffectStore");
|
||||
|
||||
export const ProfileEffectRecord: {
|
||||
|
|
@ -42,7 +39,7 @@ export interface ProfileEffectConfig {
|
|||
animationType: number;
|
||||
description: string;
|
||||
effects: {
|
||||
duartion: number;
|
||||
duration: number;
|
||||
height: number;
|
||||
loop: boolean;
|
||||
loopDelay: number;
|
||||
|
|
@ -57,7 +54,7 @@ export interface ProfileEffectConfig {
|
|||
}[];
|
||||
id: string;
|
||||
reducedMotionSrc: string;
|
||||
sku_id: string;
|
||||
skuId: string;
|
||||
staticFrameSrc?: string;
|
||||
thumbnailPreviewSrc: string;
|
||||
title: string;
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@
|
|||
|
||||
import { settings } from "..";
|
||||
import { decodeColor, decodeColorsLegacy, decodeEffect, extractFPTE } from "./fpte";
|
||||
import { ProfileEffectStore } from "./profileEffects";
|
||||
|
||||
export interface UserProfile {
|
||||
bio: string;
|
||||
premiumType: number | null | undefined;
|
||||
profileEffectId: string | undefined;
|
||||
profileEffect: any;
|
||||
themeColors: [primaryColor: number, accentColor: number] | undefined;
|
||||
}
|
||||
|
||||
|
|
@ -26,6 +28,7 @@ function updateProfileThemeColors(profile: UserProfile, primary: number, accent:
|
|||
|
||||
function updateProfileEffectId(profile: UserProfile, id: bigint) {
|
||||
if (id > -1n) {
|
||||
profile.profileEffect = ProfileEffectStore.getProfileEffectById(id.toString());
|
||||
profile.profileEffectId = id.toString();
|
||||
profile.premiumType = 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue