mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 15:52:40 +00:00
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:
commit
0e25b2d30c
2 changed files with 15 additions and 0 deletions
|
@ -131,6 +131,9 @@ final class SpaceListViewModel: SpaceListViewModelType {
|
||||||
|
|
||||||
private func loadData() {
|
private func loadData() {
|
||||||
guard let session = self.userSessionsService.mainUserSession?.matrixSession else {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,4 +246,15 @@ final class SpaceListViewModel: SpaceListViewModelType {
|
||||||
return spaceViewData.spaceId
|
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
1
changelog.d/5082.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a crash when selected space is not home and a clear cache or logout is performed.
|
Loading…
Reference in a new issue