mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Implement viewing lists on home timeline (IOS-21)
This commit is contained in:
parent
4c832d0547
commit
9cb88bcff5
@ -140,6 +140,9 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media
|
||||
case .home:
|
||||
showLocalTimelineAction.state = .off
|
||||
showFollowingAction.state = .on
|
||||
case .list:
|
||||
showLocalTimelineAction.state = .off
|
||||
showFollowingAction.state = .off
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,9 +156,11 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media
|
||||
authorization: self.authContext.mastodonAuthenticationBox.userAuthorization
|
||||
).singleOutput().value) ?? []
|
||||
|
||||
var listEntries = lists.map {
|
||||
return LabeledAction(title: $0.title, image: nil, handler: {
|
||||
assertionFailure("Not yet implemented!")
|
||||
var listEntries = lists.map { entry in
|
||||
return LabeledAction(title: entry.title, image: nil, handler: { [weak self] in
|
||||
guard let self, let viewModel = self.viewModel else { return }
|
||||
viewModel.timelineContext = .list(entry.id)
|
||||
viewModel.loadLatestStateMachine.enter(HomeTimelineViewModel.LoadLatestState.ContextSwitch.self)
|
||||
}).menuElement
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,12 @@ extension HomeTimelineViewModel.LoadLatestState {
|
||||
query: .init(local: true, sinceID: sinceID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try await viewModel.context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(sinceID: sinceID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
enter(state: Idle.self)
|
||||
|
@ -74,6 +74,12 @@ extension HomeTimelineViewModel.LoadOldestState {
|
||||
query: .init(local: true, maxID: maxID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try await viewModel.context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(local: true, maxID: maxID),
|
||||
authenticationBox: viewModel.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
let statuses = response.value
|
||||
|
@ -170,6 +170,12 @@ extension HomeTimelineViewModel {
|
||||
query: .init(local: true, maxID: status.id),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try? await context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(local: true, maxID: status.id),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
// insert missing items
|
||||
|
@ -184,6 +184,12 @@ private extension FeedDataController {
|
||||
query: .init(local: true, maxID: maxID),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
)
|
||||
case let .list(id):
|
||||
response = try await context.apiService.listTimeline(
|
||||
id: id,
|
||||
query: .init(maxID: maxID),
|
||||
authenticationBox: authContext.mastodonAuthenticationBox
|
||||
)
|
||||
}
|
||||
|
||||
return response.value.map { .fromStatus(.fromEntity($0), kind: .home) }
|
||||
|
@ -0,0 +1,26 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import CoreData
|
||||
import CoreDataStack
|
||||
import MastodonSDK
|
||||
|
||||
extension APIService {
|
||||
public func listTimeline(
|
||||
id: String,
|
||||
query: Mastodon.API.Timeline.PublicTimelineQuery,
|
||||
authenticationBox: MastodonAuthenticationBox
|
||||
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Status]> {
|
||||
let domain = authenticationBox.domain
|
||||
let authorization = authenticationBox.userAuthorization
|
||||
|
||||
let response = try await Mastodon.API.Timeline.list(
|
||||
session: session,
|
||||
domain: domain,
|
||||
query: query,
|
||||
id: id,
|
||||
authorization: authorization
|
||||
).singleOutput()
|
||||
|
||||
return response
|
||||
}
|
||||
}
|
@ -11,9 +11,10 @@ public final class MastodonFeed {
|
||||
case notificationAll
|
||||
case notificationMentions
|
||||
|
||||
public enum TimelineContext {
|
||||
public enum TimelineContext: Equatable {
|
||||
case home
|
||||
case `public`
|
||||
case list(String)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user