Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com.woltlab.wcf/templates/articleList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{if $__wcf->user->userID}
<script data-relocate="true">
require(['WoltLabSuite/Core/Ui/Article/MarkAllAsRead'], ({ setup }) => {
setup();
setup(document.getElementById('{unsafe:$listView->getID()|encodeJS}_items'));
});
</script>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion com.woltlab.wcf/templates/categoryArticleList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{if $__wcf->user->userID}
<script data-relocate="true">
require(['WoltLabSuite/Core/Ui/Article/MarkAllAsRead'], ({ setup }) => {
setup();
setup(document.getElementById('{unsafe:$listView->getID()|encodeJS}_items'));
});
</script>
{/if}
Expand Down
21 changes: 13 additions & 8 deletions ts/WoltLabSuite/Core/Ui/Article/MarkAllAsRead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
async function markAllAsRead(listView?: HTMLElement): Promise<void> {
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);
}),
);
});
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.