Skip to content

Commit 4e90145

Browse files
committed
Do not reset the filter in all cases
1 parent fa1447e commit 4e90145

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

src/api/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ pub enum Menu {
540540
ChangePass,
541541
/// The User should be presented with the main menu.
542542
Main,
543-
/// The User should be presented with a list of all the saved password `Entries`, filtered by the string provided as argument
544-
EntriesList(String),
543+
/// The User should be presented with a list of all the saved password `Entries`, optiolally filtered by the string provided as argument.
544+
EntriesList(Option<String>),
545545
/// The User should create a new `Entry`. The optional Entry argument is an initial entry from which the User could start.
546546
/// It may contain a system-generated passphrase etc.
547547
NewEntry(Option<Entry>),

src/lib.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,22 @@ impl CoreLogicHandler {
273273
.unwrap();
274274
Box::pin(future::ready(UserSelection::GoTo(Menu::Main)))
275275
}
276-
UserSelection::GoTo(Menu::EntriesList(filter)) => {
277-
debug!(
278-
"UserSelection::GoTo(Menu::EntriesList) with filter '{}'",
279-
&filter
280-
);
281-
s.safe.set_filter(filter.clone());
276+
UserSelection::GoTo(Menu::EntriesList(filter_opt)) => {
277+
match filter_opt {
278+
Some(filter) => {
279+
debug!(
280+
"UserSelection::GoTo(Menu::EntriesList) with filter '{}'",
281+
&filter
282+
);
283+
s.safe.set_filter(filter.clone());
284+
},
285+
None => {
286+
debug!(
287+
"UserSelection::GoTo(Menu::EntriesList) with existing filter '{}'",
288+
&s.safe.get_filter()
289+
);
290+
}
291+
}
282292
s.editor.show_entries(s.safe.get_entries().to_vec(), s.safe.get_filter())
283293
}
284294
UserSelection::GoTo(Menu::NewEntry(opt)) => {
@@ -442,7 +452,7 @@ impl CoreLogicHandler {
442452
if let Some(entry) = entry_to_replace_opt {
443453
s.safe.add_entry(entry);
444454
s.contents_changed = true;
445-
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList("".to_string()))))
455+
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(Some("".to_string())))))
446456
} else {
447457
Box::pin(future::ready(UserSelection::GoTo(Menu::Current)))
448458
}
@@ -495,7 +505,7 @@ impl CoreLogicHandler {
495505
let _ = s.editor.show_message("Could not replace the password entry. Please see the logs for more details.", vec![UserOption::ok()], MessageSeverity::Error).await;
496506
}
497507
}
498-
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(s.safe.get_filter()))))
508+
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(None))))
499509
} else {
500510
Box::pin(future::ready(UserSelection::GoTo(Menu::Current)))
501511
}
@@ -511,7 +521,7 @@ impl CoreLogicHandler {
511521
);
512522
});
513523
s.contents_changed = true;
514-
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList("".to_string()))))
524+
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(None))))
515525
}
516526
UserSelection::GoTo(Menu::TryFileRecovery) => {
517527
debug!("UserSelection::GoTo(Menu::TryFileRecovery)");
@@ -552,7 +562,7 @@ Warning: Saving will discard all the entries that could not be recovered.
552562
};
553563
s.safe.entries.append(&mut rec_entries);
554564

555-
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList("".to_string()))))
565+
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(Some("".to_string())))))
556566
}
557567
UserSelection::GoTo(Menu::ExportEntries) => {
558568
debug!("UserSelection::GoTo(Menu::ExportEntries)");
@@ -823,15 +833,15 @@ Warning: Saving will discard all the entries that could not be recovered.
823833
let _ = s
824834
.editor
825835
.show_message(&mr.message, mr.user_options, mr.severity).await;
826-
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList("".to_string()))))
836+
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(Some("".to_string())))))
827837
}
828838
Err(error) => {
829839
let _ = s.editor.show_message(
830840
error.to_string().as_str(),
831841
vec![UserOption::ok()],
832842
MessageSeverity::Error,
833843
).await;
834-
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList("".to_string()))))
844+
Box::pin(future::ready(UserSelection::GoTo(Menu::EntriesList(Some("".to_string())))))
835845
}
836846
}
837847
}
@@ -1086,7 +1096,7 @@ async fn handle_provided_password_for_init(
10861096
let retrieved_entries = match file_handler::load(filename, &cr, true) {
10871097
// Success, go to the List of entries
10881098
Ok(rkl_content) => {
1089-
user_selection = UserSelection::GoTo(Menu::EntriesList("".to_string()));
1099+
user_selection = UserSelection::GoTo(Menu::EntriesList(Some("".to_string())));
10901100
// Set the retrieved configuration
10911101
let new_rkl_conf = RklConfiguration::from((
10921102
rkl_content.nextcloud_conf,

tests/execution_cases.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,6 @@ async fn execute_update_configuration() {
415415
// Update the configuration
416416
UserSelection::GoTo(Menu::ShowConfiguration),
417417
UserSelection::UpdateConfiguration(new_conf),
418-
// Ack sync error message
419-
UserSelection::UserOption(UserOption::ok()),
420418
// Save
421419
UserSelection::GoTo(Menu::Save(false)),
422420
// Ack saved message

0 commit comments

Comments
 (0)