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 = {
|
const bookmarkState = {
|
||||||
items: [],
|
items: [],
|
||||||
loaded: false,
|
loaded: false,
|
||||||
loading: 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;
|
let bookmarkFetchPromise = null;
|
||||||
|
|
||||||
function formatRelativeTimeFromNow(timestamp) {
|
function formatRelativeTimeFromNow(timestamp) {
|
||||||
@@ -757,9 +769,19 @@ function openBookmark(bookmark) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const stateBookmark = bookmarkState.items.find((item) => item.id === bookmark.id) || 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({
|
upsertBookmarkInState({
|
||||||
id: stateBookmark.id,
|
id: stateBookmark.id,
|
||||||
label: stateBookmark.label,
|
label: stateBookmark.label,
|
||||||
@@ -927,7 +949,7 @@ function renderBookmarks() {
|
|||||||
id: 'default-search',
|
id: 'default-search',
|
||||||
label: 'Gewinnspiel / gewinnen / verlosen',
|
label: 'Gewinnspiel / gewinnen / verlosen',
|
||||||
query: '',
|
query: '',
|
||||||
last_clicked_at: null,
|
last_clicked_at: bookmarkState.defaultLastClickedAt || null,
|
||||||
deletable: false,
|
deletable: false,
|
||||||
isDefault: true
|
isDefault: true
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user