Skip to content

Commit

Permalink
token update fix
Browse files Browse the repository at this point in the history
  • Loading branch information
g0dm0d committed Mar 6, 2024
1 parent f09c67a commit 0165710
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 197 deletions.
2 changes: 0 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
cairo
gdk-pixbuf
glib
glibc
dbus
openssl_3
librsvg
Expand All @@ -28,7 +27,6 @@
dbus
openssl_3
glib
glibc
gtk3
libsoup
webkitgtk
Expand Down
12 changes: 3 additions & 9 deletions src-tauri/src/accounts/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn load_users() -> Result<Accounts, String> {
Ok(users)
}

fn update_user(user: &User) -> Result<(), String> {
fn update_user(user: &User) -> Result<Accounts, String> {
let mut users = load_users().map_err(|err| err.to_string())?;
let index = users
.users
Expand All @@ -118,7 +118,7 @@ fn update_user(user: &User) -> Result<(), String> {
.ok_or("User not found")?;

users.users[index] = user.clone();
Ok(())
Ok(users)
}

impl User {
Expand All @@ -144,13 +144,7 @@ impl User {

/// save user to accounts.json in launcher default foldert
pub fn save(&mut self) -> Result<(), Box<dyn std::error::Error>> {
if update_user(&*self).is_ok() {
return Ok(());
}

let user = self.clone();
let mut accounts = load_users()?;
accounts.users.push(user);
let accounts = update_user(&self)?;

fs::write(
path::get_path(USERS_FILE),
Expand Down
Loading

0 comments on commit 0165710

Please sign in to comment.