Skip to content

Commit

Permalink
⚙️(App): make params in TransferData optional
Browse files Browse the repository at this point in the history
This change wraps `MainAppParams` in an `Option` within `TransferData`, allowing for more flexible handling of parameters. The code is updated to handle the new `Option<MainAppParams>` by using `unwrap_or_default()` and `Some()` where necessary.

Signed-off-by: Benign X <[email protected]>
  • Loading branch information
W-Mai committed Nov 18, 2024
1 parent 576a754 commit 0a0f9b7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct MainAppCache {
}

#[derive(Clone, PartialEq, Decode, Encode)]

struct MainAppParams {
vis_progress: i64,
vis_progress_max: i64,
Expand All @@ -43,7 +42,7 @@ struct MainAppParams {
#[derive(Clone, PartialEq, Default, Decode, Encode)]
struct TransferData {
code: String,
params: MainAppParams,
params: Option<MainAppParams>,
}

impl Default for MainAppParams {
Expand Down Expand Up @@ -413,7 +412,7 @@ impl MainApp {
bincode::decode_from_slice(&data, config) as Result<(TransferData, _), _>
{
self.code = AnyData::new(t.code);
self.params = t.params;
self.params = t.params.unwrap_or_default();

return;
}
Expand All @@ -426,7 +425,7 @@ impl MainApp {
let history = web_sys::window().unwrap().history().unwrap();
let transfer_data = TransferData {
code: self.code.cast_ref::<String>().clone(),
params: self.params.clone(),
params: Some(self.params.clone()),
};

if self.cache.transfer_data == transfer_data {
Expand Down

0 comments on commit 0a0f9b7

Please sign in to comment.