mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 11:30:50 +02:00
SpaceList: Fix a crash when clearing cache or logout.
This commit is contained in:
@@ -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([]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user