Merge pull request #5088 from vector-im/steve/5082_fix_clear_cache

Fix a crash when selected space is not home and a clear cache or logout is performed
This commit is contained in:
SBiOSoftWhare 2021-11-04 09:22:23 +01:00 committed by GitHub
commit 0e25b2d30c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -131,6 +131,9 @@ final class SpaceListViewModel: SpaceListViewModelType {
private func loadData() {
guard let session = self.userSessionsService.mainUserSession?.matrixSession else {
// If there is no main session, reset current selection and give an empty section list
// It can happen when the user make a clear cache or logout
self.resetList()
return
}
@ -243,4 +246,15 @@ final class SpaceListViewModel: SpaceListViewModelType {
return spaceViewData.spaceId
}
}
private func resetList() {
self.sections = []
let selectedIndexPath = IndexPath(row: 0, section: 0)
self.selectedIndexPath = selectedIndexPath
self.homeIndexPath = selectedIndexPath
self.update(viewState: .loaded([]))
}
}

1
changelog.d/5082.bugfix Normal file
View file

@ -0,0 +1 @@
Fix a crash when selected space is not home and a clear cache or logout is performed.