mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-21 15:50:59 +00:00
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
3 changed files with 7 additions and 3 deletions
|
@ -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 a new issue