bookmark fix
This commit is contained in:
30
web/app.js
30
web/app.js
@@ -501,13 +501,25 @@ function sortBookmarksByRecency(list) {
|
||||
});
|
||||
}
|
||||
|
||||
const DEFAULT_BOOKMARK_LAST_CLICK_KEY = 'trackerDefaultBookmarkLastClickedAt';
|
||||
|
||||
const bookmarkState = {
|
||||
items: [],
|
||||
loaded: false,
|
||||
loading: false,
|
||||
error: null
|
||||
error: null,
|
||||
defaultLastClickedAt: null
|
||||
};
|
||||
|
||||
try {
|
||||
const storedDefaultBookmark = localStorage.getItem(DEFAULT_BOOKMARK_LAST_CLICK_KEY);
|
||||
if (storedDefaultBookmark) {
|
||||
bookmarkState.defaultLastClickedAt = storedDefaultBookmark;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Konnte letzte Nutzung des Standard-Bookmarks nicht laden:', error);
|
||||
}
|
||||
|
||||
let bookmarkFetchPromise = null;
|
||||
|
||||
function formatRelativeTimeFromNow(timestamp) {
|
||||
@@ -757,9 +769,19 @@ function openBookmark(bookmark) {
|
||||
}
|
||||
|
||||
const stateBookmark = bookmarkState.items.find((item) => item.id === bookmark.id) || bookmark;
|
||||
const isDefaultBookmark = stateBookmark && stateBookmark.isDefault;
|
||||
|
||||
if (stateBookmark && stateBookmark.id && stateBookmark.deletable !== false) {
|
||||
const nowIso = new Date().toISOString();
|
||||
const nowIso = new Date().toISOString();
|
||||
|
||||
if (isDefaultBookmark) {
|
||||
bookmarkState.defaultLastClickedAt = nowIso;
|
||||
try {
|
||||
localStorage.setItem(DEFAULT_BOOKMARK_LAST_CLICK_KEY, nowIso);
|
||||
} catch (error) {
|
||||
console.warn('Konnte Standard-Bookmark-Zeit nicht speichern:', error);
|
||||
}
|
||||
renderBookmarks();
|
||||
} else if (stateBookmark && stateBookmark.id && stateBookmark.deletable !== false) {
|
||||
upsertBookmarkInState({
|
||||
id: stateBookmark.id,
|
||||
label: stateBookmark.label,
|
||||
@@ -927,7 +949,7 @@ function renderBookmarks() {
|
||||
id: 'default-search',
|
||||
label: 'Gewinnspiel / gewinnen / verlosen',
|
||||
query: '',
|
||||
last_clicked_at: null,
|
||||
last_clicked_at: bookmarkState.defaultLastClickedAt || null,
|
||||
deletable: false,
|
||||
isDefault: true
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user