Refactoring

This commit is contained in:
Justin Mazzocchi 2022-11-27 14:17:08 -08:00
parent 457bcd7123
commit bb83a264ef
3 changed files with 6 additions and 6 deletions

View file

@ -97,11 +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 false
}
indexPath.item < lastUpdate.sections[indexPath.section].items.count
else { return nil }
let item = lastUpdate.sections[indexPath.section].items[indexPath.item]
let cachedViewModel = viewModelCache[item]

View file

@ -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)
}

View file

@ -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)
}