Fix ProfileSets Banner not loading. (#1131)

* Fix ProfileSets banner loading

* Trim ProfileSets banner fix

* Remove noisy ProfileSets changes

* Update presetManager.tsx

* Update presetManager.tsx

---------

Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
oma 2026-05-29 15:06:29 -04:00 • committed by GitHub
parent 8486c9807e
commit 2cbdc4406a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 3 deletions

View file

@ -7,7 +7,7 @@
import { Button } from "@components/Button";
import { Heading } from "@components/Heading";
import { classes } from "@utils/misc";
import { openModal,React, SelectedGuildStore, TextInput, useStateFromStores } from "@webpack/common";
import { openModal, React, SelectedGuildStore, TextInput, useStateFromStores } from "@webpack/common";
import { cl, settings } from "../index";
import { exportPresets, ImportDecision, importPresets, savePreset } from "../utils/actions";

View file

@ -57,6 +57,21 @@ function setPendingChanges(payload: Record<string, unknown>, guildId?: string) {
dispatch("USER_PROFILE_SETTINGS_SET_PENDING_CHANGES", guildId ? { guildId, ...payload } : payload);
}
function openProfileImagePreview(
uploadType: "AVATAR" | "BANNER",
image: Extract<ImageInput, { imageUri: string; }>,
guildId?: string
) {
dispatch("PROFILE_CUSTOMIZATION_OPEN_PREVIEW_MODAL", {
image,
file: {},
uploadType,
guildId,
analyticsSource: guildId ? "user settings guild profile" : "user settings user profile",
isTryItOut: false
});
}
function isNonEmptyString(value: unknown): value is string {
return typeof value === "string" && value.length > 0;
}
@ -339,7 +354,14 @@ export async function loadPresetAsPending(preset: ProfilePreset, guildId?: strin
description: `profilesets-${preset.name ?? "preset"}`
}
: avatarValue;
setPending({ pendingAvatar: avatarPayload });
const avatarImageUri = avatarPayload != null && "imageUri" in Object(avatarPayload)
? (avatarPayload as { imageUri?: unknown; }).imageUri
: null;
if (isNonEmptyString(avatarImageUri)) {
openProfileImagePreview("AVATAR", { ...Object(avatarPayload), imageUri: avatarImageUri }, guildId);
} else {
setPending({ pendingAvatar: avatarPayload });
}
}
}
@ -351,7 +373,15 @@ export async function loadPresetAsPending(preset: ProfilePreset, guildId?: strin
description: `profilesets-${preset.name ?? "preset"}`
}
: preset.bannerDataUrl;
setPending({ pendingBanner: bannerPayload });
const bannerImageUri = bannerPayload != null && "imageUri" in Object(bannerPayload)
? (bannerPayload as { imageUri?: unknown; }).imageUri
: null;
if (isNonEmptyString(bannerImageUri)) {
openProfileImagePreview("BANNER", { ...Object(bannerPayload), imageUri: bannerImageUri }, guildId);
} else {
setPending({ pendingBanner: bannerPayload });
}
}
if (!options.skipBio && preset?.bio !== current?.bio) {