Differ between local and following-timeline (IOS-235)
This commit is contained in:
parent
4eed7df729
commit
5e1bb2cfaa
|
@ -88,9 +88,19 @@ 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,10 +61,20 @@ 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
|
||||
|
|
|
@ -19,6 +19,11 @@ import MastodonSDK
|
|||
|
||||
final class HomeTimelineViewModel: NSObject {
|
||||
|
||||
enum TimelineContext {
|
||||
case following
|
||||
case community
|
||||
}
|
||||
|
||||
var disposeBag = Set<AnyCancellable>()
|
||||
var observations = Set<NSKeyValueObservation>()
|
||||
|
||||
|
@ -35,6 +40,7 @@ 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