You've already forked AstralRinth
forked from didirus/AstralRinth
Tag fetching and caching (#59)
* basic framework. still has errors * added functionality for main endpoints + some structuring * formatting * unused code * mimicked CLI function with wait_for process * added basic auth bindings * made PR changes, added playground * cargo fmt * removed missed println * misc tests fixes * cargo fmt * added windows support * cargo fmt * all OS use dunce * restructured profile slightly; fixed mac bug * profile changes, new main.rs * fixed requested pr + canonicaliation bug * fixed regressed bug in ui * fixed regressed bugs * fixed git error * typo * ran prettier * clippy * playground clippy * ported profile loading fix * profile change for real, url println and clippy * PR changes * auth bindings + semisynch flow * fixed dropping task error * prettier, eslint, clippy * removed debugging modifications * removed unused function that eslinter missed :( * initial errored push * working draft * added tag system! * fixed merge issue --------- Co-authored-by: Wyatt <wyatt@modrinth.com>
This commit is contained in:
@@ -28,6 +28,9 @@ pub use self::children::*;
|
||||
mod auth_task;
|
||||
pub use self::auth_task::*;
|
||||
|
||||
mod tags;
|
||||
pub use self::tags::*;
|
||||
|
||||
// Global state
|
||||
static LAUNCHER_STATE: OnceCell<Arc<State>> = OnceCell::const_new();
|
||||
pub struct State {
|
||||
@@ -50,6 +53,8 @@ pub struct State {
|
||||
pub(crate) profiles: RwLock<Profiles>,
|
||||
/// Launcher user account info
|
||||
pub(crate) users: RwLock<Users>,
|
||||
/// Launcher tags
|
||||
pub(crate) tags: RwLock<Tags>,
|
||||
}
|
||||
|
||||
impl State {
|
||||
@@ -87,6 +92,15 @@ impl State {
|
||||
|
||||
let auth_flow = AuthTask::new();
|
||||
|
||||
// On launcher initialization, attempt a tag fetch after tags init
|
||||
let mut tags = Tags::init(&database)?;
|
||||
if let Err(tag_fetch_err) = tags.fetch_update().await {
|
||||
tracing::error!(
|
||||
"Failed to fetch tags on launcher init: {}",
|
||||
tag_fetch_err
|
||||
);
|
||||
};
|
||||
|
||||
Ok(Arc::new(Self {
|
||||
database,
|
||||
directories,
|
||||
@@ -97,6 +111,7 @@ impl State {
|
||||
users: RwLock::new(users),
|
||||
children: RwLock::new(children),
|
||||
auth_flow: RwLock::new(auth_flow),
|
||||
tags: RwLock::new(tags),
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user