Skip to content

Commit d96f8d5

Browse files
committed
Discard the dialog after uploading an avatar or cover photo
These take effect immediately because the file itself is being replaced by merely uploading it. See https://www.woltlab.com/community/thread/314498/ See woltlab.com/community/thread/314499/
1 parent 2a6556f commit d96f8d5

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

ts/WoltLabSuite/Core/Component/User/Avatar.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function editAvatar(button: HTMLElement): Promise<void> {
4141

4242
export function setup(): void {
4343
wheneverFirstSeen(
44-
"#wcf\\\\action\\\\UserAvatarAction_avatarFileIDContainer woltlab-core-file img",
44+
`#wcf\\\\action\\\\UserAvatarAction_avatarFileIDContainer woltlab-core-file img`,
4545
(img: HTMLImageElement) => {
4646
img.classList.add("userAvatarImage");
4747
img.parentElement!.classList.add("userAvatar");
@@ -62,6 +62,18 @@ export function setup(): void {
6262
avatarForm.querySelector<HTMLImageElement>("img.userAvatarImage")!.src = file.link!;
6363
showDefaultSuccessSnackbar();
6464
});
65+
} else {
66+
registerCallback("wcf\\action\\UserAvatarAction_avatarFileID", (fileId: number | undefined) => {
67+
if (fileId === undefined) {
68+
return;
69+
}
70+
71+
document
72+
.getElementById("wcf\\action\\UserAvatarAction_avatarFileIDContainer")
73+
?.closest("woltlab-core-dialog")
74+
?.querySelector<HTMLButtonElement>(".dialog__control__button--primary")
75+
?.click();
76+
});
6577
}
6678

6779
wheneverFirstSeen("[data-edit-avatar]", (button) => {

ts/WoltLabSuite/Core/Component/User/CoverPhoto.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export function setup(): void {
7070
coverPhotoElement.src = coverPhotoUrl;
7171

7272
coverPhotoElement.dataset.objectId = fileId?.toString() || "";
73+
74+
document
75+
.getElementById("wcf\\action\\UserCoverPhotoAction_coverPhotoFileIDContainer")
76+
?.closest("woltlab-core-dialog")
77+
?.close();
7378
} else {
7479
// ACP cover photo management
7580
if (!coverPhotoElement && coverPhotoUrl) {

wcfsetup/install/files/js/WoltLabSuite/Core/Component/User/Avatar.js

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wcfsetup/install/files/js/WoltLabSuite/Core/Component/User/CoverPhoto.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)