elk-zone / elk-native

Native version of Elk, a nimble Mastodon web
MIT License
377 stars 17 forks source link

feat: add system tray icon, keep app running when closed #58

Open marekvospel opened 1 year ago

marekvospel commented 1 year ago

This pull request adds a system tray and the common behavior of applications not stopping when closed with the option to reopen it inside the system tray.

Related

https://github.com/elk-zone/elk/pull/1414

stackblitz[bot] commented 1 year ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

marekvospel commented 1 year ago

It seems there was a WindowBuilder::with_config method, but it seems to have been removed :confused:

For the minimize to tray disabling some UI might need to be added to elk upstream repository, which I'm not sure I can do, as I'm not that familiar with it's source & tauri in general (the APIs for communication between frontend and the tauri application)

marekvospel commented 1 year ago

As mentioned in the Elk discord server

If the initial value is true, min: Some(Bool(true)) gets printed, when I change it to false from the frontend, eventhough the file & the UI on the frontend changed, I still get min: Some(Bool(true)).

If the initial value is false, I get min: Some(Bool(false)) and after changing it from the frontend to true, the correct min: Some(Bool(true)) (also in the file). But now after I change it to false again, everything updates, except for the returned value from store, which stays min: Some(Bool(true))

Basically changing false -> true works, changing true -> false doesn't

               let stores = app.state::<StoreCollection<Wry>>();
               let mut path = app.path_resolver().app_data_dir().unwrap();
               path.push("settings.json");

               with_store(app.clone(), stores, path, |store| {
                   println!("min: {:?}", store.get("minimize_to_tray"));
                   let result = match store.get("minimize_to_tray") {
                       Some(serde_json::Value::Bool(value)) => value,
                       _ => &true,
                  };
               })

https://discord.com/channels/1044887051155292200/1050490177304408074/1067554891049996398