Differ between local and following-timeline (IOS-235)
This commit is contained in:
parent
4eed7df729
commit
5e1bb2cfaa
|
@ -88,10 +88,20 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
|
||||
do {
|
||||
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
||||
let response = try await viewModel.context.apiService.homeTimeline(
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
|
||||
let response: Mastodon.Response.Content<[Mastodon.Entity.Status]>
|
||||
|
||||
switch viewModel.timelineContext {
|
||||
case .following:
|
||||
response = try await viewModel.context.apiService.homeTimeline(
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case .community:
|
||||
response = try await viewModel.context.apiService.publicTimeline(
|
||||
query: .init(local: true),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
await enter(state: Idle.self)
|
||||
viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.finished)
|
||||
|
||||
|
|
|
@ -53,9 +53,7 @@ extension HomeTimelineViewModel.LoadOldestState {
|
|||
}
|
||||
|
||||
Task {
|
||||
let _maxID = lastFeedRecord.status?.id
|
||||
|
||||
guard let maxID = _maxID else {
|
||||
guard let maxID = lastFeedRecord.status?.id else {
|
||||
await self.enter(state: Fail.self)
|
||||
return
|
||||
}
|
||||
|
@ -63,11 +61,21 @@ extension HomeTimelineViewModel.LoadOldestState {
|
|||
do {
|
||||
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
||||
|
||||
let response = try await viewModel.context.apiService.homeTimeline(
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
|
||||
let response: Mastodon.Response.Content<[Mastodon.Entity.Status]>
|
||||
|
||||
switch viewModel.timelineContext {
|
||||
case .following:
|
||||
response = try await viewModel.context.apiService.homeTimeline(
|
||||
maxID: maxID,
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case .community:
|
||||
response = try await viewModel.context.apiService.publicTimeline(
|
||||
query: .init(local: true, maxID: maxID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
let statuses = response.value
|
||||
// enter no more state when no new statuses
|
||||
if statuses.isEmpty || (statuses.count == 1 && statuses[0].id == maxID) {
|
||||
|
|
|
@ -18,7 +18,12 @@ import MastodonUI
|
|||
import MastodonSDK
|
||||
|
||||
final class HomeTimelineViewModel: NSObject {
|
||||
|
||||
|
||||
enum TimelineContext {
|
||||
case following
|
||||
case community
|
||||
}
|
||||
|
||||
var disposeBag = Set<AnyCancellable>()
|
||||
var observations = Set<NSKeyValueObservation>()
|
||||
|
||||
|
@ -35,7 +40,8 @@ final class HomeTimelineViewModel: NSObject {
|
|||
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
||||
@Published var displaySettingBarButtonItem = true
|
||||
@Published var hasPendingStatusEditReload = false
|
||||
|
||||
var timelineContext: TimelineContext = .following
|
||||
|
||||
weak var tableView: UITableView?
|
||||
weak var timelineMiddleLoaderTableViewCellDelegate: TimelineMiddleLoaderTableViewCellDelegate?
|
||||
|
||||
|
|
Loading…
Reference in New Issue