fix crash when trying to rename a filter profile to a name that already exists

This commit is contained in:
johan12345
2024-10-15 20:11:56 +02:00
parent ce618f81e4
commit aa07da1002
3 changed files with 12 additions and 2 deletions

View File

@@ -188,9 +188,17 @@ class FilterProfilesFragment : Fragment() {
dialog.setTitle(R.string.rename)
.setMessage(R.string.save_profile_enter_name)
}, {
}, { newName ->
lifecycleScope.launch {
vm.update(fp.copy(name = it))
if (vm.filterProfiles.value?.find { it.name == newName } != null) {
Snackbar.make(
view,
R.string.filterprofile_name_not_unique,
Snackbar.LENGTH_LONG
).show()
} else {
vm.update(fp.copy(name = newName))
}
}
})
})

View File

@@ -152,6 +152,7 @@
<string name="delete">Löschen</string>
<string name="save_as_profile">Als Profil speichern</string>
<string name="save_profile_enter_name">Gib den Namen des Filterprofils ein:</string>
<string name="filterprofile_name_not_unique">Ein Filterprofil mit diesem Namen existiert bereits</string>
<string name="filterprofiles_empty_state">Du hast keine Filterprofile gespeichert</string>
<string name="welcome_to_evmap">Willkommen bei EVMap</string>
<string name="welcome_1">Finde Ladestationen für Elektroautos in deiner Nähe</string>

View File

@@ -152,6 +152,7 @@
<string name="delete">Delete</string>
<string name="save_as_profile">Save as profile</string>
<string name="save_profile_enter_name">Enter the name of the filter profile:</string>
<string name="filterprofile_name_not_unique">There is already a filter profile with that name</string>
<string name="filterprofiles_empty_state">You have no filter profiles saved</string>
<string name="welcome_to_evmap">Welcome to EVMap</string>
<string name="welcome_1">Find electric vehicle chargers around you</string>