From dace63e30685506b55fed56bd383782d9d84695c Mon Sep 17 00:00:00 2001 From: Astra Date: Wed, 3 Jul 2024 18:38:23 +0900 Subject: [PATCH] Fix iButton/LFRFID Add Manually results being discarded --- .../ibutton/scenes/ibutton_scene_add_value.c | 31 +++++++++++-------- .../lfrfid/scenes/lfrfid_scene_save_data.c | 20 +++++++----- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/applications/main/ibutton/scenes/ibutton_scene_add_value.c b/applications/main/ibutton/scenes/ibutton_scene_add_value.c index 622ed5ad3fc..9815e52814a 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(scene_manager_has_previous_scene(scene_manager, iButtonSceneAddType)) { + ibutton_protocols_apply_edits(ibutton->protocols, ibutton->key); + scene_manager_next_scene(scene_manager, iButtonSceneSaveName); + } else { + 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(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 { + 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 5d5371e9137..20c8a10df7b 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) {