Reset the cache of a popover
authorAlexander Ebert <ebert@woltlab.com>
Fri, 28 Jul 2023 13:35:46 +0000 (15:35 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 28 Jul 2023 13:35:46 +0000 (15:35 +0200)
ts/WoltLabSuite/Core/Controller/Popover.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Popover.js

index cf7ac0b76164f0b154b64edc373529c651085fc0..eea5fa06839e488756d786c266e76eb01e0319f9 100644 (file)
@@ -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);
+}
index 120420cb9944f0ea4ac08c0fe37c47b06b32fbc5..5edc87520c6b9e865d58d7bb43b85c3cdeebe7f9 100644 (file)
@@ -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;
 });