-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: sender error after account switch (#297) * Sender error after account switch * fix: typo * Implement account note feature for enhanced account management (#298) (#299) * Changes info icon on the wallet view * Updates Cargo.lock file * Fixes balance info for different locales than en-US * Adds persistence to locale preference * Changes app name from Carpe to carpe * Inits account events on account switch * Fixes displaying events of an account off chain * Adds optimistic account switch Clean up code * Unsubscribes Miner subscriptions onDestroy * Optimizes Miner components subscriptions * UX - Adds tower state skeleton * Fixes wallet components memory leak Fixes coin print according to language selected Clean up code * Adds coin transfer - WIP * Do not notify initial account selection * Transfers coins * Coin transfer adjustments * Translates onboard and transfer buttons * Fixes modal close on success * Fixes onboard modal close onSucess * Fixes events pagination vertical alignment * Fixes check sender vs receiver addresses * Adds sent payments to be displayed on the events tab * Adds wallet skeleton Update libra branch version * Removes viewport from components to avoid vertical scroll bar * Adds lang missing keys * Adds missing language keys * Fixes printCoins for Chinese * Fix rust code getting best fullnode url * Wait for account to be loaded before showing scanning for fullnodes * Hides make whole navbar link * removes events tab * adds account note feature - WIP * improves account note feature saves accounts list sort and order preferences optimizes svelte components load * hides total balance and unlocked when there is only one account avoids wrap line on table header * removes console.log * clean warnings * assigns note to account on switch signingAccount --------- Co-authored-by: BBK <chnqbj@gmail.com> Co-authored-by: soaresa <10797037+soaresa@users.noreply.github.com>
- Loading branch information
1 parent
752bee2
commit b0304ec
Showing
28 changed files
with
573 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
pub(crate) mod app_version; | ||
pub(crate) mod mining; | ||
// pub(crate) mod mining; | ||
pub(crate) mod networks; | ||
pub(crate) mod preferences; | ||
pub(crate) mod query; | ||
pub(crate) mod tx; | ||
pub(crate) mod wallets; | ||
pub(crate) mod web_logs; | ||
pub(crate) mod user_preferences; | ||
|
||
//pub use app_version::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use crate::carpe_error::CarpeError; | ||
use serde::{Deserialize, Serialize}; | ||
use std::fs::{File, OpenOptions}; | ||
use std::io::{Read, Write}; | ||
use std::path::{PathBuf}; | ||
use crate::configs::default_config_path; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct UserPreferences { | ||
accounts_list_sort_column: Option<String>, | ||
accounts_list_sort_order: Option<String>, | ||
} | ||
|
||
// Utility function to retrieve the full path to the preferences file | ||
fn get_preferences_path() -> Result<PathBuf, CarpeError> { | ||
let app_dir_path = default_config_path(); // Assuming this returns a PathBuf or Path | ||
|
||
// Check if the path exists, if not, return an error | ||
if !app_dir_path.exists() { | ||
return Err(CarpeError::misc("App directory not found")); | ||
} | ||
|
||
Ok(app_dir_path.join("user_preferences.json")) | ||
} | ||
|
||
#[tauri::command(async)] | ||
pub async fn get_user_preferences() -> Result<UserPreferences, CarpeError> { | ||
let file_path = get_preferences_path()?; | ||
match File::open(&file_path) { | ||
Ok(mut file) => { | ||
let mut contents = String::new(); | ||
if let Err(e) = file.read_to_string(&mut contents) { | ||
return Err(CarpeError::misc(&format!("Failed to read from preferences file: {}", e))); | ||
} | ||
serde_json::from_str(&contents).map_err(|e| CarpeError::misc(&format!("Failed to parse preferences: {}", e))) | ||
}, | ||
Err(e) => Err(CarpeError::misc(&format!("Failed to open preferences file: {}", e))), | ||
} | ||
} | ||
|
||
#[tauri::command(async)] | ||
pub async fn set_accounts_list_preference(sort_column: String, sort_order: String) -> Result<(), CarpeError> { | ||
let file_path = get_preferences_path()?; | ||
let mut file = OpenOptions::new() | ||
.write(true) | ||
.create(true) | ||
.truncate(true) | ||
.open(&file_path) | ||
.map_err(|e| CarpeError::misc(&format!("Failed to open preferences file for writing: {}", e)))?; | ||
|
||
let preferences = UserPreferences { | ||
accounts_list_sort_column: Some(sort_column), | ||
accounts_list_sort_order: Some(sort_order), | ||
}; | ||
|
||
let serialized_data = serde_json::to_string_pretty(&preferences) | ||
.map_err(|e| CarpeError::misc(&format!("Failed to serialize preferences: {}", e)))?; | ||
|
||
file.write_all(serialized_data.as_bytes()) | ||
.map_err(|e| CarpeError::misc(&format!("Failed to write preferences file: {}", e))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.