diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-26 20:04:07 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-26 20:04:07 +0300 |
commit | 1b67f05a148e7d9480e5b97b70d4af72ce551485 (patch) | |
tree | df561ae49810f5c571c81031c5d660b35667e40a /src/bookmarks.c | |
parent | ff459a750f2c810142636bf292cdd36cb6a911aa (diff) |
Bookmarks: New items added to end of lists
Use max order for new bookmarks and folders.
Diffstat (limited to 'src/bookmarks.c')
-rw-r--r-- | src/bookmarks.c | 10 |
1 files changed, 10 insertions, 0 deletions
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) { | |||
327 | unlock_Mutex(d->mtx); | 327 | unlock_Mutex(d->mtx); |
328 | } | 328 | } |
329 | 329 | ||
330 | static int maxOrder_Bookmarks_(const iBookmarks *d) { | ||
331 | int ord = 0; | ||
332 | iConstForEach(Hash, i, &d->bookmarks) { | ||
333 | const iBookmark *bm = (const iBookmark *) i.value; | ||
334 | ord = iMax(ord, bm->order); | ||
335 | } | ||
336 | return ord; | ||
337 | } | ||
338 | |||
330 | uint32_t add_Bookmarks(iBookmarks *d, const iString *url, const iString *title, const iString *tags, | 339 | uint32_t add_Bookmarks(iBookmarks *d, const iString *url, const iString *title, const iString *tags, |
331 | iChar icon) { | 340 | iChar icon) { |
332 | lock_Mutex(d->mtx); | 341 | lock_Mutex(d->mtx); |
@@ -340,6 +349,7 @@ uint32_t add_Bookmarks(iBookmarks *d, const iString *url, const iString *title, | |||
340 | } | 349 | } |
341 | bm->icon = icon; | 350 | bm->icon = icon; |
342 | initCurrent_Time(&bm->when); | 351 | initCurrent_Time(&bm->when); |
352 | bm->order = maxOrder_Bookmarks_(d) + 1; /* Last in lists. */ | ||
343 | insert_Bookmarks_(d, bm); | 353 | insert_Bookmarks_(d, bm); |
344 | unlock_Mutex(d->mtx); | 354 | unlock_Mutex(d->mtx); |
345 | return id_Bookmark(bm); | 355 | return id_Bookmark(bm); |