11/**
22 * Handles the 'mark as read' action for articles.
33 *
4- * @author Marcel Werk
5- * @copyright 2001-2023 WoltLab GmbH
6- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
4+ * @author Marcel Werk
5+ * @copyright 2001-2026 WoltLab GmbH
6+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7+ * @since 6.3
78 * @woltlabExcludeBundle tiny
89 */
910
1011import { showDefaultSuccessSnackbar } from "WoltLabSuite/Core/Component/Snackbar" ;
1112import { markAllArticlesAsRead } from "WoltLabSuite/Core/Api/Articles/MarkAllArticlesAsRead" ;
1213import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex" ;
1314
14- async function markAllAsRead ( listView ?: HTMLElement ) : Promise < void > {
15+ async function markAllAsRead ( button : HTMLElement , listView ?: HTMLElement ) : Promise < void > {
1516 await markAllArticlesAsRead ( ) ;
1617
1718 if ( listView !== undefined ) {
@@ -20,16 +21,16 @@ async function markAllAsRead(listView?: HTMLElement): Promise<void> {
2021
2122 document . querySelectorAll ( ".boxMenu .active .badgeUpdate" ) . forEach ( ( el : HTMLElement ) => el . remove ( ) ) ;
2223
24+ button . remove ( ) ;
25+
2326 showDefaultSuccessSnackbar ( ) ;
2427}
2528
26- export function setup ( listView ?: HTMLElement ) : void {
27- document . querySelectorAll ( ".markAllAsReadButton" ) . forEach ( ( el : HTMLElement ) => {
28- el . addEventListener (
29- "click" ,
30- promiseMutex ( async ( ) => {
31- await markAllAsRead ( listView ) ;
32- } ) ,
33- ) ;
34- } ) ;
29+ export function setup ( button : HTMLElement , listView ?: HTMLElement ) : void {
30+ button . addEventListener (
31+ "click" ,
32+ promiseMutex ( async ( ) => {
33+ await markAllAsRead ( button , listView ) ;
34+ } ) ,
35+ ) ;
3536}
0 commit comments