Fix crash when muting account (#245)
* Workaround crash when muting account * Refactoring Co-authored-by: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com>
This commit is contained in:
parent
b42dd286e6
commit
8692b8c9e8
|
@ -97,7 +97,11 @@ public class CollectionItemsViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
// swiftlint:disable:next function_body_length cyclomatic_complexity
|
// swiftlint:disable:next function_body_length cyclomatic_complexity
|
||||||
public func viewModel(indexPath: IndexPath) -> Any {
|
public func viewModel(indexPath: IndexPath) -> Any? {
|
||||||
|
guard indexPath.section < lastUpdate.sections.count,
|
||||||
|
indexPath.item < lastUpdate.sections[indexPath.section].items.count
|
||||||
|
else { return nil }
|
||||||
|
|
||||||
let item = lastUpdate.sections[indexPath.section].items[indexPath.item]
|
let item = lastUpdate.sections[indexPath.section].items[indexPath.item]
|
||||||
let cachedViewModel = viewModelCache[item]
|
let cachedViewModel = viewModelCache[item]
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ public protocol CollectionViewModel {
|
||||||
func viewedAtTop(indexPath: IndexPath)
|
func viewedAtTop(indexPath: IndexPath)
|
||||||
func select(indexPath: IndexPath)
|
func select(indexPath: IndexPath)
|
||||||
func canSelect(indexPath: IndexPath) -> Bool
|
func canSelect(indexPath: IndexPath) -> Bool
|
||||||
func viewModel(indexPath: IndexPath) -> Any
|
func viewModel(indexPath: IndexPath) -> Any?
|
||||||
func toggleExpandAll()
|
func toggleExpandAll()
|
||||||
func applyAccountListEdit(viewModel: AccountViewModel, edit: CollectionItemEvent.AccountListEdit)
|
func applyAccountListEdit(viewModel: AccountViewModel, edit: CollectionItemEvent.AccountListEdit)
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ extension ProfileViewModel: CollectionViewModel {
|
||||||
collectionViewModel.value.canSelect(indexPath: indexPath)
|
collectionViewModel.value.canSelect(indexPath: indexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func viewModel(indexPath: IndexPath) -> Any {
|
public func viewModel(indexPath: IndexPath) -> Any? {
|
||||||
collectionViewModel.value.viewModel(indexPath: indexPath)
|
collectionViewModel.value.viewModel(indexPath: indexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue