From d43a6b3c5ca2788d2195bf233f055af974ba4c92 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 28 Jul 2023 15:35:46 +0200 Subject: [PATCH] Reset the cache of a popover --- ts/WoltLabSuite/Core/Controller/Popover.ts | 19 +++++++++++++++++++ .../WoltLabSuite/Core/Controller/Popover.js | 19 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ts/WoltLabSuite/Core/Controller/Popover.ts b/ts/WoltLabSuite/Core/Controller/Popover.ts index cf7ac0b761..eea5fa0683 100644 --- a/ts/WoltLabSuite/Core/Controller/Popover.ts +++ b/ts/WoltLabSuite/Core/Controller/Popover.ts @@ -237,6 +237,18 @@ class ControllerPopover implements AjaxCallbackObject { } } + resetCache(identifier: string, objectId: number): void { + const cacheId = `${identifier}-${objectId}`; + if (!this.cache.has(cacheId)) { + return; + } + + this.cache.set(cacheId, { + content: null, + state: State.None, + }); + } + /** * Handles the mouse start hovering the popover-enabled element. */ @@ -486,3 +498,10 @@ export function setContent(identifier: string, objectId: number, content: string export function ajaxApi(data: RequestPayload, success: CallbackSuccess, failure: CallbackFailure): void { getControllerPopover().ajaxApi(data, success, failure); } + +/** + * Resets the cached data for an object. + */ +export function resetCache(identifier: string, objectId: number): void { + getControllerPopover().resetCache(identifier, objectId); +} diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Popover.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Popover.js index 120420cb99..5edc87520c 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Popover.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Popover.js @@ -8,7 +8,7 @@ define(["require", "exports", "tslib", "../Ajax", "../Dom/Change/Listener", "../Dom/Util", "../Environment", "../Ui/Alignment"], function (require, exports, tslib_1, Ajax, Listener_1, Util_1, Environment, UiAlignment) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.ajaxApi = exports.setContent = exports.init = void 0; + exports.resetCache = exports.ajaxApi = exports.setContent = exports.init = void 0; Ajax = tslib_1.__importStar(Ajax); Listener_1 = tslib_1.__importDefault(Listener_1); Util_1 = tslib_1.__importDefault(Util_1); @@ -166,6 +166,16 @@ define(["require", "exports", "tslib", "../Ajax", "../Dom/Change/Listener", "../ } } } + resetCache(identifier, objectId) { + const cacheId = `${identifier}-${objectId}`; + if (!this.cache.has(cacheId)) { + return; + } + this.cache.set(cacheId, { + content: null, + state: 0 /* State.None */, + }); + } /** * Handles the mouse start hovering the popover-enabled element. */ @@ -372,4 +382,11 @@ define(["require", "exports", "tslib", "../Ajax", "../Dom/Change/Listener", "../ getControllerPopover().ajaxApi(data, success, failure); } exports.ajaxApi = ajaxApi; + /** + * Resets the cached data for an object. + */ + function resetCache(identifier, objectId) { + getControllerPopover().resetCache(identifier, objectId); + } + exports.resetCache = resetCache; }); -- 2.20.1