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 {
|
do {
|
||||||
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
||||||
let response = try await viewModel.context.apiService.homeTimeline(
|
let response: Mastodon.Response.Content<[Mastodon.Entity.Status]>
|
||||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
|
||||||
)
|
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)
|
await enter(state: Idle.self)
|
||||||
viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.finished)
|
viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.finished)
|
||||||
|
|
|
@ -53,9 +53,7 @@ extension HomeTimelineViewModel.LoadOldestState {
|
||||||
}
|
}
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
let _maxID = lastFeedRecord.status?.id
|
guard let maxID = lastFeedRecord.status?.id else {
|
||||||
|
|
||||||
guard let maxID = _maxID else {
|
|
||||||
await self.enter(state: Fail.self)
|
await self.enter(state: Fail.self)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -63,10 +61,20 @@ extension HomeTimelineViewModel.LoadOldestState {
|
||||||
do {
|
do {
|
||||||
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
await AuthenticationServiceProvider.shared.fetchAccounts(apiService: viewModel.context.apiService)
|
||||||
|
|
||||||
let response = try await viewModel.context.apiService.homeTimeline(
|
let response: Mastodon.Response.Content<[Mastodon.Entity.Status]>
|
||||||
maxID: maxID,
|
|
||||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
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
|
let statuses = response.value
|
||||||
// enter no more state when no new statuses
|
// enter no more state when no new statuses
|
||||||
|
|
|
@ -19,6 +19,11 @@ import MastodonSDK
|
||||||
|
|
||||||
final class HomeTimelineViewModel: NSObject {
|
final class HomeTimelineViewModel: NSObject {
|
||||||
|
|
||||||
|
enum TimelineContext {
|
||||||
|
case following
|
||||||
|
case community
|
||||||
|
}
|
||||||
|
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
var observations = Set<NSKeyValueObservation>()
|
var observations = Set<NSKeyValueObservation>()
|
||||||
|
|
||||||
|
@ -35,6 +40,7 @@ final class HomeTimelineViewModel: NSObject {
|
||||||
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
@Published var scrollPositionRecord: ScrollPositionRecord? = nil
|
||||||
@Published var displaySettingBarButtonItem = true
|
@Published var displaySettingBarButtonItem = true
|
||||||
@Published var hasPendingStatusEditReload = false
|
@Published var hasPendingStatusEditReload = false
|
||||||
|
var timelineContext: TimelineContext = .following
|
||||||
|
|
||||||
weak var tableView: UITableView?
|
weak var tableView: UITableView?
|
||||||
weak var timelineMiddleLoaderTableViewCellDelegate: TimelineMiddleLoaderTableViewCellDelegate?
|
weak var timelineMiddleLoaderTableViewCellDelegate: TimelineMiddleLoaderTableViewCellDelegate?
|
||||||
|
|
Loading…
Reference in New Issue