Tag rendering

This commit is contained in:
Justin Mazzocchi 2020-09-14 22:29:48 -07:00
parent d7c99a08a8
commit 9e98beedbd
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
3 changed files with 20 additions and 1 deletions

View File

@ -10,6 +10,7 @@ public struct StatusListService {
public let statusSections: AnyPublisher<[[Status]], Error>
public let paginates: Bool
public let contextParentID: String?
public var title: String?
private let filterContext: Filter.Context
private let mastodonAPIClient: MastodonAPIClient
@ -28,9 +29,16 @@ extension StatusListService {
filterContext = .public
}
var title: String?
if case let .tag(tag) = timeline {
title = "#".appending(tag)
}
self.init(statusSections: contentDatabase.statusesObservation(timeline: timeline),
paginates: true,
contextParentID: nil,
title: title,
filterContext: filterContext,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase) { maxID, minID in
@ -54,10 +62,15 @@ public extension StatusListService {
StatusService(status: status, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
}
func service(timeline: Timeline) -> Self {
Self(timeline: timeline, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
}
func contextService(statusID: String) -> Self {
Self(statusSections: contentDatabase.contextObservation(parentID: statusID),
paginates: false,
contextParentID: statusID,
title: nil,
filterContext: .thread,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase) { _, _ in

View File

@ -49,6 +49,8 @@ final class StatusListViewController: UITableViewController {
tableView.cellLayoutMarginsFollowReadableWidth = true
tableView.tableFooterView = UIView()
navigationItem.title = viewModel.title
viewModel.$statusIDs
.sink { [weak self] statusIDs in
guard let self = self else { return }

View File

@ -46,6 +46,8 @@ public extension StatusListViewModel {
}
public extension StatusListViewModel {
var title: String? { statusListService.title }
var paginates: Bool { statusListService.paginates }
var contextParentID: String? { statusListService.contextParentID }
@ -121,7 +123,9 @@ private extension StatusListViewModel {
StatusListViewModel(
statusListService: statusListService.contextService(statusID: id)))
case let .tag(tag):
return nil
return .statusListNavigation(
StatusListViewModel(
statusListService: statusListService.service(timeline: Timeline.tag(tag))))
}
case let .share(url):
return .share(url)