Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Add simple http #67

wants to merge 11 commits into from

Conversation

petrvecera
Copy link
Member

No description provided.

@petrvecera petrvecera marked this pull request as ready for review February 25, 2024 18:28
Comment on lines +9 to +21
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
}
Copy link
Collaborator

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.

Copy link
Member Author

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.

@petrvecera
Copy link
Member Author

wtf github is bugged again it's not showing my latest commit?

@petrvecera petrvecera closed this Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants