mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 08:21:47 +00:00
Maintain GLOBALS.current_bookmarks as a resolved Vec<Id> via a periodic task
This commit is contained in:
parent
8867cedc64
commit
b38fa8b87b
@ -157,6 +157,9 @@ pub struct Globals {
|
||||
|
||||
/// Bookmarks
|
||||
pub bookmarks: PRwLock<BookmarkList>,
|
||||
|
||||
/// Current bookmarks, resolved into a Vec<Id> (updated by tasks)
|
||||
pub current_bookmarks: PRwLock<Vec<Id>>,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
@ -226,6 +229,7 @@ lazy_static! {
|
||||
pending: Pending::new(),
|
||||
loading_more: AtomicUsize::new(0),
|
||||
bookmarks: PRwLock::new(BookmarkList::empty()),
|
||||
current_bookmarks: PRwLock::new(Vec::new()),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -75,4 +75,12 @@ async fn do_general_tasks(tick: usize) {
|
||||
GLOBALS.unread_dms.store(unread, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
// Update current bookmarks from bookmarks (every 2 seconds)
|
||||
if tick % 2 == 0 {
|
||||
match GLOBALS.bookmarks.read().get_bookmark_feed() {
|
||||
Ok(feed) => *GLOBALS.current_bookmarks.write() = feed,
|
||||
Err(e) => tracing::error!("{:?}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user