diff --git a/com.woltlab.wcf/templates/articleList.tpl b/com.woltlab.wcf/templates/articleList.tpl index 1c3fa082ddf..67d5f0aba3a 100644 --- a/com.woltlab.wcf/templates/articleList.tpl +++ b/com.woltlab.wcf/templates/articleList.tpl @@ -39,7 +39,7 @@ {if $__wcf->user->userID} {/if} diff --git a/com.woltlab.wcf/templates/categoryArticleList.tpl b/com.woltlab.wcf/templates/categoryArticleList.tpl index 48240cf333e..2faab6f276c 100644 --- a/com.woltlab.wcf/templates/categoryArticleList.tpl +++ b/com.woltlab.wcf/templates/categoryArticleList.tpl @@ -46,7 +46,7 @@ {if $__wcf->user->userID} {/if} diff --git a/ts/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.ts b/ts/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.ts index 3fc77fc6b16..1445b46a135 100644 --- a/ts/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.ts +++ b/ts/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.ts @@ -9,22 +9,27 @@ import { showDefaultSuccessSnackbar } from "WoltLabSuite/Core/Component/Snackbar"; import { dboAction } from "../../Ajax"; +import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex"; -async function markAllAsRead(): Promise { +async function markAllAsRead(listView?: HTMLElement): Promise { await dboAction("markAllAsRead", "wcf\\data\\article\\ArticleAction").dispatch(); - document.querySelectorAll(".contentItemList .contentItemBadgeNew").forEach((el: HTMLElement) => el.remove()); + if (listView !== undefined) { + listView.dispatchEvent(new CustomEvent("interaction:invalidate-all")); + } + document.querySelectorAll(".boxMenu .active .badgeUpdate").forEach((el: HTMLElement) => el.remove()); showDefaultSuccessSnackbar(); } -export function setup(): void { +export function setup(listView?: HTMLElement): void { document.querySelectorAll(".markAllAsReadButton").forEach((el: HTMLElement) => { - el.addEventListener("click", (event) => { - event.preventDefault(); - - void markAllAsRead(); - }); + el.addEventListener( + "click", + promiseMutex(async () => { + await markAllAsRead(listView); + }), + ); }); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.js index 57137e914e2..293230730b1 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.js @@ -6,22 +6,23 @@ * @license GNU Lesser General Public License * @woltlabExcludeBundle tiny */ -define(["require", "exports", "WoltLabSuite/Core/Component/Snackbar", "../../Ajax"], function (require, exports, Snackbar_1, Ajax_1) { +define(["require", "exports", "WoltLabSuite/Core/Component/Snackbar", "../../Ajax", "WoltLabSuite/Core/Helper/PromiseMutex"], function (require, exports, Snackbar_1, Ajax_1, PromiseMutex_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setup = setup; - async function markAllAsRead() { + async function markAllAsRead(listView) { await (0, Ajax_1.dboAction)("markAllAsRead", "wcf\\data\\article\\ArticleAction").dispatch(); - document.querySelectorAll(".contentItemList .contentItemBadgeNew").forEach((el) => el.remove()); + if (listView !== undefined) { + listView.dispatchEvent(new CustomEvent("interaction:invalidate-all")); + } document.querySelectorAll(".boxMenu .active .badgeUpdate").forEach((el) => el.remove()); (0, Snackbar_1.showDefaultSuccessSnackbar)(); } - function setup() { + function setup(listView) { document.querySelectorAll(".markAllAsReadButton").forEach((el) => { - el.addEventListener("click", (event) => { - event.preventDefault(); - void markAllAsRead(); - }); + el.addEventListener("click", (0, PromiseMutex_1.promiseMutex)(async () => { + await markAllAsRead(listView); + })); }); } });