Do not try to modify datasource directly (IOS-266)
This commit is contained in:
parent
a59ab43bec
commit
7b5b0dacc7
|
@ -150,20 +150,15 @@ extension HomeTimelineViewModel {
|
|||
func loadMore(item: StatusItem, indexPath: IndexPath) async {
|
||||
guard case let .feedLoader(record) = item else { return }
|
||||
guard let diffableDataSource = diffableDataSource else { return }
|
||||
var snapshot = diffableDataSource.snapshot()
|
||||
|
||||
guard let status = record.status else { return }
|
||||
record.isLoadingMore = true
|
||||
|
||||
// reconfigure item
|
||||
snapshot.reconfigureItems([item])
|
||||
updateSnapshotUsingReloadData(snapshot: snapshot)
|
||||
|
||||
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: context.apiService)
|
||||
|
||||
// fetch data
|
||||
let response = try? await context.apiService.homeTimeline(
|
||||
sinceID: status.id,
|
||||
maxID: status.id,
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
)
|
||||
|
||||
|
@ -180,10 +175,8 @@ extension HomeTimelineViewModel {
|
|||
|
||||
record.isLoadingMore = false
|
||||
record.hasMore = false
|
||||
updateSnapshotUsingReloadData(snapshot: snapshot)
|
||||
} else {
|
||||
record.isLoadingMore = false
|
||||
updateSnapshotUsingReloadData(snapshot: snapshot)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ extension StatusTableViewCell {
|
|||
case .feed(let feed):
|
||||
statusView.configure(feed: feed)
|
||||
self.separatorLine.isHidden = feed.hasMore
|
||||
feed.$hasMore.sink(receiveValue: { [weak self] hasMore in
|
||||
self?.separatorLine.isHidden = hasMore
|
||||
})
|
||||
.store(in: &disposeBag)
|
||||
|
||||
case .status(let status):
|
||||
statusView.configure(status: status)
|
||||
|
|
|
@ -18,7 +18,11 @@ public final class MastodonFeed {
|
|||
}
|
||||
|
||||
public let id: String
|
||||
|
||||
@Published
|
||||
public var hasMore: Bool = false
|
||||
|
||||
@Published
|
||||
public var isLoadingMore: Bool = false
|
||||
|
||||
public let status: MastodonStatus?
|
||||
|
|
|
@ -37,8 +37,10 @@ extension TimelineMiddleLoaderTableViewCell {
|
|||
feed: MastodonFeed,
|
||||
delegate: TimelineMiddleLoaderTableViewCellDelegate?
|
||||
) {
|
||||
self.viewModel.isFetching = feed.isLoadingMore
|
||||
|
||||
feed.$isLoadingMore
|
||||
.assign(to: \.isFetching, on: self.viewModel)
|
||||
.store(in: &disposeBag)
|
||||
|
||||
self.delegate = delegate
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue