Merge branch '5.5'
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / js / WoltLabSuite / Core / Conversation / Ui / MarkAllAsRead.js
1 /**
2 * Marks all conversations as read.
3 *
4 * @author Marcel Werk
5 * @copyright 2001-2022 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @since 6.0
8 */
9 define(["require", "exports", "tslib", "WoltLabSuite/Core/Ajax", "WoltLabSuite/Core/Ui/Notification"], function (require, exports, tslib_1, Ajax_1, UiNotification) {
10 "use strict";
11 Object.defineProperty(exports, "__esModule", { value: true });
12 exports.setup = void 0;
13 UiNotification = tslib_1.__importStar(UiNotification);
14 async function markAllAsRead() {
15 await (0, Ajax_1.dboAction)("markAllAsRead", "wcf\\data\\conversation\\ConversationAction").dispatch();
16 document.querySelectorAll(".conversationList .new").forEach((el) => {
17 el.classList.remove("new");
18 });
19 document.querySelector("#unreadConversations .badgeUpdate")?.remove();
20 UiNotification.show();
21 }
22 function setup() {
23 document.querySelectorAll(".markAllAsReadButton").forEach((el) => {
24 el.addEventListener("click", (event) => {
25 event.preventDefault();
26 void markAllAsRead();
27 });
28 });
29 }
30 exports.setup = setup;
31 });