Skip to content

Commit 04f0b38

Browse files
authored
Merge pull request #6588 from WoltLab/62-articles-mark-as-read
Fix removal of the 'new' badges when marking all articles as read
2 parents 267aa72 + b58c3bf commit 04f0b38

4 files changed

Lines changed: 24 additions & 18 deletions

File tree

com.woltlab.wcf/templates/articleList.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{if $__wcf->user->userID}
4040
<script data-relocate="true">
4141
require(['WoltLabSuite/Core/Ui/Article/MarkAllAsRead'], ({ setup }) => {
42-
setup();
42+
setup(document.getElementById('{unsafe:$listView->getID()|encodeJS}_items'));
4343
});
4444
</script>
4545
{/if}

com.woltlab.wcf/templates/categoryArticleList.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{if $__wcf->user->userID}
4747
<script data-relocate="true">
4848
require(['WoltLabSuite/Core/Ui/Article/MarkAllAsRead'], ({ setup }) => {
49-
setup();
49+
setup(document.getElementById('{unsafe:$listView->getID()|encodeJS}_items'));
5050
});
5151
</script>
5252
{/if}

ts/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@
99

1010
import { showDefaultSuccessSnackbar } from "WoltLabSuite/Core/Component/Snackbar";
1111
import { dboAction } from "../../Ajax";
12+
import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex";
1213

13-
async function markAllAsRead(): Promise<void> {
14+
async function markAllAsRead(listView?: HTMLElement): Promise<void> {
1415
await dboAction("markAllAsRead", "wcf\\data\\article\\ArticleAction").dispatch();
1516

16-
document.querySelectorAll(".contentItemList .contentItemBadgeNew").forEach((el: HTMLElement) => el.remove());
17+
if (listView !== undefined) {
18+
listView.dispatchEvent(new CustomEvent("interaction:invalidate-all"));
19+
}
20+
1721
document.querySelectorAll(".boxMenu .active .badgeUpdate").forEach((el: HTMLElement) => el.remove());
1822

1923
showDefaultSuccessSnackbar();
2024
}
2125

22-
export function setup(): void {
26+
export function setup(listView?: HTMLElement): void {
2327
document.querySelectorAll(".markAllAsReadButton").forEach((el: HTMLElement) => {
24-
el.addEventListener("click", (event) => {
25-
event.preventDefault();
26-
27-
void markAllAsRead();
28-
});
28+
el.addEventListener(
29+
"click",
30+
promiseMutex(async () => {
31+
await markAllAsRead(listView);
32+
}),
33+
);
2934
});
3035
}

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.js

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)