File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
app/src/main/java/com/vladshurakov/jetnotesapp/feature_settings/presenter/screen Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -76,16 +76,20 @@ fun SettingsScreen(
7676 val json = navController.context.contentResolver.openInputStream(uri).use {
7777 it?.bufferedReader()?.readText() ? : " []"
7878 }
79- val type: Type = object : TypeToken <List <Note >>() {}.type
80- val notes = Gson ().fromJson<List <Note >>(json, type).toMutableList()
81- /*
79+ try {
80+ val type: Type = object : TypeToken <List <Note >>() {}.type
81+ val notes = Gson ().fromJson<List <Note >>(json, type).toMutableList()
82+ /*
8283 * It changes id to null to auto-generate new id
8384 * (will be duplicated without it)
8485 */
85- notes.onEachIndexed { index, note ->
86- notes[index] = note.copy(id = null )
86+ notes.onEachIndexed { index, note ->
87+ notes[index] = note.copy(id = null )
88+ }
89+ settingsViewModel.onEvent(SettingsEvent .InsertNotes (notes))
90+ }catch (e: java.lang.Exception ){
91+ return @rememberLauncherForActivityResult
8792 }
88- settingsViewModel.onEvent(SettingsEvent .InsertNotes (notes))
8993 }
9094
9195 val isStyleDialogOpen = remember {
You can’t perform that action at this time.
0 commit comments