mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-21 07:41:00 +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
|
||||
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 cachedViewModel = viewModelCache[item]
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public protocol CollectionViewModel {
|
|||
func viewedAtTop(indexPath: IndexPath)
|
||||
func select(indexPath: IndexPath)
|
||||
func canSelect(indexPath: IndexPath) -> Bool
|
||||
func viewModel(indexPath: IndexPath) -> Any
|
||||
func viewModel(indexPath: IndexPath) -> Any?
|
||||
func toggleExpandAll()
|
||||
func applyAccountListEdit(viewModel: AccountViewModel, edit: CollectionItemEvent.AccountListEdit)
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ extension ProfileViewModel: CollectionViewModel {
|
|||
collectionViewModel.value.canSelect(indexPath: indexPath)
|
||||
}
|
||||
|
||||
public func viewModel(indexPath: IndexPath) -> Any {
|
||||
public func viewModel(indexPath: IndexPath) -> Any? {
|
||||
collectionViewModel.value.viewModel(indexPath: indexPath)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue