Skip to content

Commit bdc3704

Browse files
committed
migrating the previous orphaned rooms settings in order to fix the inconsistent value
- only uses the previous value if the key exists, otherwise we end up defaulting to true instead of false (which the preferences screen expects) - manually deletes the key after migrating the value
1 parent 6a2a69a commit bdc3704

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

changelog.d/6510.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes inconsistency with rooms within spaces showing or disappearing from home

vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,20 +1020,32 @@ class VectorPreferences @Inject constructor(
10201020
}
10211021
}
10221022

1023-
private fun labsSpacesOnlyOrphansInHome(): Boolean {
1024-
return defaultPrefs.getBoolean(SETTINGS_LABS_SPACES_HOME_AS_ORPHAN, false)
1025-
}
1026-
10271023
fun labsAutoReportUISI(): Boolean {
10281024
return defaultPrefs.getBoolean(SETTINGS_LABS_AUTO_REPORT_UISI, false)
10291025
}
10301026

10311027
fun prefSpacesShowAllRoomInHome(): Boolean {
1032-
return defaultPrefs.getBoolean(
1033-
SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME,
1034-
// migration of old property
1035-
!labsSpacesOnlyOrphansInHome()
1036-
)
1028+
val defaultValue = false
1029+
return when {
1030+
defaultPrefs.contains(SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME) -> {
1031+
defaultPrefs.getBoolean(SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME, defaultValue)
1032+
}
1033+
defaultPrefs.contains(SETTINGS_LABS_SPACES_HOME_AS_ORPHAN) -> migrateOrphansInSpacesToShowAllInHome()
1034+
else -> defaultValue
1035+
}
1036+
}
1037+
1038+
private fun migrateOrphansInSpacesToShowAllInHome(): Boolean {
1039+
val showAllRoomsInHome = !labsSpacesOnlyOrphansInHome()
1040+
defaultPrefs.edit {
1041+
putBoolean(SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME, showAllRoomsInHome)
1042+
remove(SETTINGS_LABS_SPACES_HOME_AS_ORPHAN)
1043+
}
1044+
return showAllRoomsInHome
1045+
}
1046+
1047+
private fun labsSpacesOnlyOrphansInHome(): Boolean {
1048+
return defaultPrefs.getBoolean(SETTINGS_LABS_SPACES_HOME_AS_ORPHAN, false)
10371049
}
10381050

10391051
/*

0 commit comments

Comments
 (0)