Don't accept template to render the quote container content
authorCyperghost <olaf_schmitz_1@t-online.de>
Tue, 17 Dec 2024 12:55:00 +0000 (13:55 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Tue, 17 Dec 2024 12:55:00 +0000 (13:55 +0100)
ts/WoltLabSuite/Core/Component/Quote/List.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Quote/List.js

index 27604f26b607bcfd7a1826159ddb91ebd6d0e73d..2af4d50bc0335c868af275caaf723cfffadce048 100644 (file)
@@ -28,21 +28,17 @@ class QuoteList {
       throw new Error(`The quotes container for '${editorId}' does not exist.`);
     }
 
-    window.addEventListener("storage", (event) => {
-      if (event.key !== STORAGE_KEY) {
-        return;
-      }
-
-      this.renderQuotes(event.newValue);
+    window.addEventListener("storage", () => {
+      this.renderQuotes();
     });
 
-    this.renderQuotes(window.localStorage.getItem(STORAGE_KEY));
+    this.renderQuotes();
   }
 
-  public renderQuotes(template: string | null): void {
-    this.#container.innerHTML = template || "";
+  public renderQuotes(): void {
+    this.#container.innerHTML = window.localStorage.getItem(STORAGE_KEY) || "";
 
-    if (template) {
+    if (this.#container.hasChildNodes()) {
       getTabMenu(this.#editorId)?.showTab(
         "quotes",
         getPhrase("wcf.message.quote.showQuotes", {
index c00ea38c3130afe9ac8935811f11aa35f649449c..39105e436a20af298cd8302ceb364248c3d1551a 100644 (file)
@@ -18,17 +18,14 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Core", "WoltLabSuite/C
             if (this.#container === null) {
                 throw new Error(`The quotes container for '${editorId}' does not exist.`);
             }
-            window.addEventListener("storage", (event) => {
-                if (event.key !== exports.STORAGE_KEY) {
-                    return;
-                }
-                this.renderQuotes(event.newValue);
+            window.addEventListener("storage", () => {
+                this.renderQuotes();
             });
-            this.renderQuotes(window.localStorage.getItem(exports.STORAGE_KEY));
+            this.renderQuotes();
         }
-        renderQuotes(template) {
-            this.#container.innerHTML = template || "";
-            if (template) {
+        renderQuotes() {
+            this.#container.innerHTML = window.localStorage.getItem(exports.STORAGE_KEY) || "";
+            if (this.#container.hasChildNodes()) {
                 (0, MessageTabMenu_1.getTabMenu)(this.#editorId)?.showTab("quotes", (0, Language_1.getPhrase)("wcf.message.quote.showQuotes", {
                     count: this.#container.childElementCount,
                 }));