这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
58 changes: 33 additions & 25 deletions internal/ui/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,32 +274,45 @@ function goToListItem(offset) {
return;
}

if (document.querySelector(".current-item") === null) {
const currentItem = document.querySelector(".current-item");

// If no current item exists, select the first item
if (!currentItem) {
items[0].classList.add("current-item");
items[0].focus();
scrollPageTo(items[0]);
return;
}

for (let i = 0; i < items.length; i++) {
if (items[i].classList.contains("current-item")) {
items[i].classList.remove("current-item");

// By default adjust selection to the next item
let itemOffset = (i + offset + items.length) % items.length;
// Allow jumping to top or bottom
if (offset === TOP) {
itemOffset = 0;
} else if (offset === BOTTOM) {
itemOffset = items.length - 1;
}
const item = items[itemOffset];
// Find the index of the current item
const currentIndex = items.indexOf(currentItem);
if (currentIndex === -1) {
// Current item not found in visible items, select first item
currentItem.classList.remove("current-item");
items[0].classList.add("current-item");
items[0].focus();
scrollPageTo(items[0]);
return;
}

item.classList.add("current-item");
scrollPageTo(item);
item.focus();
// Calculate the new item index
let newIndex;
if (offset === TOP) {
newIndex = 0;
} else if (offset === BOTTOM) {
newIndex = items.length - 1;
} else {
newIndex = (currentIndex + offset + items.length) % items.length;
}

break;
}
// Update selection if moving to a different item
if (newIndex !== currentIndex) {
const newItem = items[newIndex];

currentItem.classList.remove("current-item");
newItem.classList.add("current-item");
newItem.focus();
scrollPageTo(newItem);
}
}

Expand Down Expand Up @@ -593,12 +606,7 @@ function updateEntriesStatus(entryIDs, status, callback) {
if (callback) {
callback(resp);
}

if (status === "read") {
updateUnreadCounterValue(-count);
} else {
updateUnreadCounterValue(count);
}
updateUnreadCounterValue(status === "read" ? -count : count);
});
});
}
Expand Down
Loading