From 2715d9a0e17bc0a71acd7599547033d430a92ff5 Mon Sep 17 00:00:00 2001 From: Astra <93453568+Astrrra@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:44:17 +0900 Subject: [PATCH] [FL-3752] Fix iButton/LFRFID Add Manually results being discarded (#3749) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- .../ibutton/scenes/ibutton_scene_add_value.c | 33 +++++++++++-------- .../lfrfid/scenes/lfrfid_scene_save_data.c | 20 ++++++----- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/applications/main/ibutton/scenes/ibutton_scene_add_value.c b/applications/main/ibutton/scenes/ibutton_scene_add_value.c index 622ed5ad3..9815e5281 100644 --- a/applications/main/ibutton/scenes/ibutton_scene_add_value.c +++ b/applications/main/ibutton/scenes/ibutton_scene_add_value.c @@ -36,21 +36,26 @@ bool ibutton_scene_add_value_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { consumed = true; if(event.event == iButtonCustomEventByteEditResult) { - furi_string_printf( - ibutton->file_path, - "%s/%s%s", - IBUTTON_APP_FOLDER, - ibutton->key_name, - IBUTTON_APP_FILENAME_EXTENSION); - - if(ibutton_save_key(ibutton)) { - scene_manager_next_scene(ibutton->scene_manager, iButtonSceneSaveSuccess); - + if(scene_manager_has_previous_scene(scene_manager, iButtonSceneAddType)) { + ibutton_protocols_apply_edits(ibutton->protocols, ibutton->key); + scene_manager_next_scene(scene_manager, iButtonSceneSaveName); } else { - const uint32_t possible_scenes[] = { - iButtonSceneReadKeyMenu, iButtonSceneSavedKeyMenu, iButtonSceneAddType}; - scene_manager_search_and_switch_to_previous_scene_one_of( - ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes)); + furi_string_printf( + ibutton->file_path, + "%s/%s%s", + IBUTTON_APP_FOLDER, + ibutton->key_name, + IBUTTON_APP_FILENAME_EXTENSION); + + if(ibutton_save_key(ibutton)) { + scene_manager_next_scene(ibutton->scene_manager, iButtonSceneSaveSuccess); + + } else { + const uint32_t possible_scenes[] = { + iButtonSceneReadKeyMenu, iButtonSceneSavedKeyMenu, iButtonSceneAddType}; + scene_manager_search_and_switch_to_previous_scene_one_of( + ibutton->scene_manager, possible_scenes, COUNT_OF(possible_scenes)); + } } } else if(event.event == iButtonCustomEventByteEditChanged) { ibutton_protocols_apply_edits(ibutton->protocols, ibutton->key); diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c b/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c index 5d5371e91..20c8a10df 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_save_data.c @@ -32,15 +32,19 @@ bool lfrfid_scene_save_data_on_event(void* context, SceneManagerEvent event) { size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id); protocol_dict_set_data(app->dict, app->protocol_id, app->new_key_data, size); - if(!furi_string_empty(app->file_name)) { - lfrfid_delete_key(app); - } - - if(lfrfid_save_key(app)) { - scene_manager_next_scene(scene_manager, LfRfidSceneSaveSuccess); + if(scene_manager_has_previous_scene(scene_manager, LfRfidSceneSaveType)) { + scene_manager_next_scene(scene_manager, LfRfidSceneSaveName); } else { - scene_manager_search_and_switch_to_previous_scene( - scene_manager, LfRfidSceneSavedKeyMenu); + if(!furi_string_empty(app->file_name)) { + lfrfid_delete_key(app); + } + + if(lfrfid_save_key(app)) { + scene_manager_next_scene(scene_manager, LfRfidSceneSaveSuccess); + } else { + scene_manager_search_and_switch_to_previous_scene( + scene_manager, LfRfidSceneSavedKeyMenu); + } } } } else if(event.type == SceneManagerEventTypeBack) {