Skip to content

Commit 21b96a1

Browse files
committed
Use FileRuntimeCache
Show notification when avatar changes in acp
1 parent 0944073 commit 21b96a1

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex";
1111
import { wheneverFirstSeen } from "WoltLabSuite/Core/Helper/Selector";
1212
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
13+
import { show as showNotification } from "WoltLabSuite/Core/Ui/Notification";
1314
import UiCloseOverlay from "WoltLabSuite/Core/Ui/CloseOverlay";
1415

1516
interface Result {
@@ -27,8 +28,8 @@ async function editAvatar(button: HTMLElement): Promise<void> {
2728
if (avatarForm) {
2829
// In the ACP, the form should not be reloaded after changing the avatar.
2930
avatarForm.querySelector<HTMLImageElement>("img.userAvatarImage")!.src = result.avatar;
31+
showNotification();
3032
} else {
31-
// TODO can we simple replace all avatar images?
3233
window.location.reload();
3334
}
3435
}

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

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

wcfsetup/install/files/lib/acp/form/UserEditForm.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use wcf\data\user\UserEditor;
1212
use wcf\data\user\UserProfileAction;
1313
use wcf\form\AbstractForm;
14+
use wcf\system\cache\runtime\FileRuntimeCache;
1415
use wcf\system\cache\runtime\UserProfileRuntimeCache;
1516
use wcf\system\exception\IllegalLinkException;
1617
use wcf\system\exception\PermissionDeniedException;
@@ -290,7 +291,7 @@ public function readData()
290291

291292
// get the avatar object
292293
if ($this->avatarType == 'custom' && $this->user->avatarFileID) {
293-
$this->userAvatar = new File($this->user->avatarFileID);
294+
$this->userAvatar = FileRuntimeCache::getInstance()->getObject($this->user->avatarFileID);
294295
}
295296

296297
// get the user cover photo object

wcfsetup/install/files/lib/data/attachment/Attachment.class.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace wcf\data\attachment;
44

55
use wcf\data\DatabaseObject;
6+
use wcf\data\file\File;
67
use wcf\data\ILinkableObject;
78
use wcf\data\IThumbnailFile;
8-
use wcf\data\file\File;
9-
use wcf\data\file\thumbnail\FileThumbnailList;
109
use wcf\data\object\type\ObjectTypeCache;
10+
use wcf\system\cache\runtime\FileRuntimeCache;
1111
use wcf\system\request\IRouteController;
1212
use wcf\system\request\LinkHandler;
1313
use wcf\system\WCF;
@@ -375,14 +375,7 @@ public function getFile(): ?File
375375
}
376376

377377
if (!isset($this->file)) {
378-
$this->file = new File($fileID);
379-
380-
$thumbnailList = new FileThumbnailList();
381-
$thumbnailList->getConditionBuilder()->add("fileID = ?", [$this->file->fileID]);
382-
$thumbnailList->readObjects();
383-
foreach ($thumbnailList as $thumbnail) {
384-
$this->file->addThumbnail($thumbnail);
385-
}
378+
$this->file = FileRuntimeCache::getInstance()->getObject($fileID);
386379
}
387380

388381
return $this->file;

0 commit comments

Comments
 (0)