-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple http #67
Add simple http #67
Conversation
* Add notifications * Fix prettier
# Conflicts: # src-tauri/src/dp_utils.rs # src-tauri/src/lib.rs # src-tauri/src/main.rs
pub fn load_store<R: Runtime>(handle: AppHandle<R>) -> Store<R> { | ||
let mut store = StoreBuilder::new(handle, PathBuf::from("config.dat")).build(); | ||
|
||
if let Err(err) = store.load() { | ||
warn!("error loading store from disk: {err}"); | ||
info!("saving store file to disk"); | ||
if let Err(err) = store.save() { | ||
warn!("error saving store file to disk: {err}"); | ||
} | ||
} | ||
|
||
store | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this was how I was doing it originally, but it unfortunately doesn't play well with Javascript changes to the store because the JS changes don't update this Rust state struct. What I'd recommend is extracting this function instead: https://github.com/cohstats/coh3-stats-desktop-app/blob/master/src-tauri/src/plugins/cohdb/sync/mod.rs#L138
It's generic over any deserializable object, so it'll work for anything that can be deserialized from JSON (primitives, strings, and structs that derive Deserialize
should all work here). You'll probably have to tell the compiler what type you're expecting though (you can see an example of that here: https://github.com/cohstats/coh3-stats-desktop-app/blob/master/src-tauri/src/plugins/cohdb/sync/mod.rs#L165).
I don't have time now but I can probably take a look at this sometime next week if you have trouble with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I will take a look, looking at my code I have no idea why is there the store.save() :D I guess I was happy that it works.
My implementation is counting with need to restart the APP, because I would have to handle it using events I guess and I don't think it's necessary right.
wtf github is bugged again it's not showing my latest commit? |
No description provided.