Move GLOBALS accessors into Globals impl

This commit is contained in:
Mike Dilger 2022-12-24 13:11:51 +13:00
parent 91b0c5bd6f
commit 2be8b12ffd
2 changed files with 66 additions and 63 deletions

View File

@ -69,6 +69,7 @@ lazy_static! {
};
}
impl Globals {
#[allow(dead_code)]
pub async fn get_feed(threaded: bool) -> Vec<Id> {
let feed: Vec<FeedEvent> = GLOBALS
@ -88,7 +89,7 @@ pub async fn get_feed(threaded: bool) -> Vec<Id> {
.cloned()
.collect();
sort_feed(feed, threaded)
Self::sort_feed(feed, threaded)
}
#[allow(dead_code)]
@ -109,7 +110,7 @@ pub fn blocking_get_feed(threaded: bool) -> Vec<Id> {
.cloned()
.collect();
sort_feed(feed, threaded)
Self::sort_feed(feed, threaded)
}
fn sort_feed(mut feed: Vec<FeedEvent>, threaded: bool) -> Vec<Id> {
@ -135,6 +136,7 @@ fn sort_feed(mut feed: Vec<FeedEvent>, threaded: bool) -> Vec<Id> {
feed.iter().map(|e| e.id).collect()
}
}
pub async fn add_event(event: &Event) -> Result<(), Error> {
// Insert the event

View File

@ -1,11 +1,12 @@
use super::GossipUi;
use crate::globals::Globals;
use eframe::egui;
use egui::{Align, Color32, Context, Layout, RichText, ScrollArea, TextStyle, Ui, Vec2};
use nostr_types::{EventKind, Id, PublicKey};
use tracing::info;
pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Frame, ui: &mut Ui) {
let feed = crate::globals::blocking_get_feed(true);
let feed = Globals::blocking_get_feed(true);
//let screen_rect = ctx.input().screen_rect; // Rect