|
@@ -5,6 +5,7 @@ void nfc_playlist_nfc_add_menu_callback(void* context) {
|
|
|
|
|
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
Stream* stream = file_stream_alloc(storage);
|
|
Stream* stream = file_stream_alloc(storage);
|
|
|
|
|
+ bool item_already_in_playlist = false;
|
|
|
|
|
|
|
|
if(file_stream_open(
|
|
if(file_stream_open(
|
|
|
stream,
|
|
stream,
|
|
@@ -14,28 +15,34 @@ void nfc_playlist_nfc_add_menu_callback(void* context) {
|
|
|
FuriString* line = furi_string_alloc();
|
|
FuriString* line = furi_string_alloc();
|
|
|
FuriString* tmp_str = furi_string_alloc();
|
|
FuriString* tmp_str = furi_string_alloc();
|
|
|
while(stream_read_line(stream, line)) {
|
|
while(stream_read_line(stream, line)) {
|
|
|
|
|
+ if(furi_string_cmp(line, nfc_playlist->file_browser_output) == 0) {
|
|
|
|
|
+ item_already_in_playlist = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(line));
|
|
furi_string_cat_printf(tmp_str, "%s", furi_string_get_cstr(line));
|
|
|
}
|
|
}
|
|
|
furi_string_free(line);
|
|
furi_string_free(line);
|
|
|
-
|
|
|
|
|
- if(!furi_string_empty(tmp_str)) {
|
|
|
|
|
- furi_string_cat_printf(tmp_str, "\n");
|
|
|
|
|
|
|
+ if(!item_already_in_playlist) {
|
|
|
|
|
+ if(!furi_string_empty(tmp_str)) {
|
|
|
|
|
+ furi_string_cat(tmp_str, "\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ furi_string_cat(tmp_str, furi_string_get_cstr(nfc_playlist->file_browser_output));
|
|
|
|
|
+ stream_clean(stream);
|
|
|
|
|
+ stream_write_string(stream, tmp_str);
|
|
|
|
|
+ nfc_playlist->settings.playlist_length++;
|
|
|
|
|
+ furi_string_reset(nfc_playlist->file_browser_output);
|
|
|
}
|
|
}
|
|
|
- furi_string_cat_printf(
|
|
|
|
|
- tmp_str, "%s", furi_string_get_cstr(nfc_playlist->file_browser_output));
|
|
|
|
|
-
|
|
|
|
|
- stream_clean(stream);
|
|
|
|
|
- stream_write_string(stream, tmp_str);
|
|
|
|
|
file_stream_close(stream);
|
|
file_stream_close(stream);
|
|
|
furi_string_free(tmp_str);
|
|
furi_string_free(tmp_str);
|
|
|
- nfc_playlist->settings.playlist_length++;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
stream_free(stream);
|
|
stream_free(stream);
|
|
|
furi_record_close(RECORD_STORAGE);
|
|
furi_record_close(RECORD_STORAGE);
|
|
|
- furi_string_reset(nfc_playlist->file_browser_output);
|
|
|
|
|
-
|
|
|
|
|
- scene_manager_previous_scene(nfc_playlist->scene_manager);
|
|
|
|
|
|
|
+ if(!item_already_in_playlist) {
|
|
|
|
|
+ scene_manager_previous_scene(nfc_playlist->scene_manager);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ scene_manager_next_scene(nfc_playlist->scene_manager, NfcPlaylistScene_NfcDuplicate);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void nfc_playlist_nfc_add_scene_on_enter(void* context) {
|
|
void nfc_playlist_nfc_add_scene_on_enter(void* context) {
|