Skip to content

Commit 4ace959

Browse files
jvoisinfguillot
authored andcommitted
refactor(js): use replace instead of remove+add.
1 parent 14f3195 commit 4ace959

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

internal/ui/static/js/app.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,7 @@ function toggleEntryStatus(element, toasting) {
648648
showToastNotification(newStatus, currentStatus === "read" ? buttonElement.dataset.toastUnread : buttonElement.dataset.toastRead);
649649
}
650650

651-
if (element.classList.contains("item-status-" + currentStatus)) {
652-
element.classList.remove("item-status-" + currentStatus);
653-
element.classList.add("item-status-" + newStatus);
654-
}
651+
element.classList.replace("item-status-" + currentStatus, "item-status-" + newStatus);
655652

656653
if (isListView() && getVisibleEntries().length === 0) {
657654
window.location.reload();
@@ -821,10 +818,7 @@ function openOriginalLinkFromListView() {
821818
goToListItem(1);
822819

823820
// Mark as read if currently unread
824-
if (currentItem.classList.contains("item-status-unread")) {
825-
currentItem.classList.remove("item-status-unread");
826-
currentItem.classList.add("item-status-read");
827-
821+
if (currentItem.classList.replace("item-status-unread", "item-status-read")) {
828822
const entryID = parseInt(currentItem.dataset.id, 10);
829823
updateEntriesStatus([entryID], "read");
830824
}

0 commit comments

Comments
 (0)