From 1b67f05a148e7d9480e5b97b70d4af72ce551485 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 26 Sep 2021 20:04:07 +0300 Subject: Bookmarks: New items added to end of lists Use max order for new bookmarks and folders. --- src/bookmarks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bookmarks.c b/src/bookmarks.c index fe2ca47a..67c6a25f 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c @@ -327,6 +327,15 @@ void save_Bookmarks(const iBookmarks *d, const char *dirPath) { unlock_Mutex(d->mtx); } +static int maxOrder_Bookmarks_(const iBookmarks *d) { + int ord = 0; + iConstForEach(Hash, i, &d->bookmarks) { + const iBookmark *bm = (const iBookmark *) i.value; + ord = iMax(ord, bm->order); + } + return ord; +} + uint32_t add_Bookmarks(iBookmarks *d, const iString *url, const iString *title, const iString *tags, iChar icon) { lock_Mutex(d->mtx); @@ -340,6 +349,7 @@ uint32_t add_Bookmarks(iBookmarks *d, const iString *url, const iString *title, } bm->icon = icon; initCurrent_Time(&bm->when); + bm->order = maxOrder_Bookmarks_(d) + 1; /* Last in lists. */ insert_Bookmarks_(d, bm); unlock_Mutex(d->mtx); return id_Bookmark(bm); -- cgit v1.2.3