chore: rename Toot -> Status
This commit is contained in:
parent
412a7dc508
commit
28cfe96171
|
@ -14,11 +14,11 @@ import CoreDataStack
|
|||
// MARK: - StatusProvider
|
||||
extension HashtagTimelineViewController: StatusProvider {
|
||||
|
||||
func toot() -> Future<Toot?, Never> {
|
||||
func status() -> Future<Status?, Never> {
|
||||
return Future { promise in promise(.success(nil)) }
|
||||
}
|
||||
|
||||
func toot(for cell: UITableViewCell, indexPath: IndexPath?) -> Future<Toot?, Never> {
|
||||
func status(for cell: UITableViewCell, indexPath: IndexPath?) -> Future<Status?, Never> {
|
||||
return Future { promise in
|
||||
guard let diffableDataSource = self.viewModel.diffableDataSource else {
|
||||
assertionFailure()
|
||||
|
@ -36,7 +36,7 @@ extension HashtagTimelineViewController: StatusProvider {
|
|||
let managedObjectContext = self.viewModel.context.managedObjectContext
|
||||
managedObjectContext.perform {
|
||||
let timelineIndex = managedObjectContext.object(with: objectID) as? HomeTimelineIndex
|
||||
promise(.success(timelineIndex?.toot))
|
||||
promise(.success(timelineIndex?.status))
|
||||
}
|
||||
default:
|
||||
promise(.success(nil))
|
||||
|
@ -44,7 +44,7 @@ extension HashtagTimelineViewController: StatusProvider {
|
|||
}
|
||||
}
|
||||
|
||||
func toot(for cell: UICollectionViewCell) -> Future<Toot?, Never> {
|
||||
func status(for cell: UICollectionViewCell) -> Future<Status?, Never> {
|
||||
return Future { promise in promise(.success(nil)) }
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ extension HashtagTimelineViewController: UITableViewDataSourcePrefetching {
|
|||
|
||||
// MARK: - TimelineMiddleLoaderTableViewCellDelegate
|
||||
extension HashtagTimelineViewController: TimelineMiddleLoaderTableViewCellDelegate {
|
||||
func configure(cell: TimelineMiddleLoaderTableViewCell, upperTimelineTootID: String?, timelineIndexobjectID: NSManagedObjectID?) {
|
||||
func configure(cell: TimelineMiddleLoaderTableViewCell, upperTimelineStatusID: String?, timelineIndexobjectID: NSManagedObjectID?) {
|
||||
guard let upperTimelineIndexObjectID = timelineIndexobjectID else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -56,13 +56,13 @@ extension HashtagTimelineViewModel: NSFetchedResultsControllerDelegate {
|
|||
let snapshot = snapshot as NSDiffableDataSourceSnapshot<Int, NSManagedObjectID>
|
||||
|
||||
let statusItemList: [Item] = snapshot.itemIdentifiers.map {
|
||||
let status = managedObjectContext.object(with: $0) as! Toot
|
||||
let status = managedObjectContext.object(with: $0) as! Status
|
||||
|
||||
let isStatusTextSensitive: Bool = {
|
||||
guard let spoilerText = status.spoilerText, !spoilerText.isEmpty else { return false }
|
||||
return true
|
||||
}()
|
||||
return Item.toot(objectID: $0, attribute: Item.StatusAttribute(isStatusTextSensitive: isStatusTextSensitive, isStatusSensitive: status.sensitive))
|
||||
return Item.status(objectID: $0, attribute: Item.StatusAttribute(isStatusTextSensitive: isStatusTextSensitive, isStatusSensitive: status.sensitive))
|
||||
}
|
||||
|
||||
var newSnapshot = NSDiffableDataSourceSnapshot<StatusSection, Item>()
|
||||
|
|
|
@ -58,7 +58,7 @@ extension HashtagTimelineViewModel.LoadLatestState {
|
|||
case .failure(let error):
|
||||
// TODO: handle error
|
||||
viewModel.isFetchingLatestTimeline.value = false
|
||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch toots failed. %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch statues failed. %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
||||
case .finished:
|
||||
// handle isFetchingLatestTimeline in fetch controller delegate
|
||||
break
|
||||
|
@ -83,7 +83,7 @@ extension HashtagTimelineViewModel.LoadLatestState {
|
|||
viewModel.hashtagStatusIDList.insert(contentsOf: newStatusIDList, at: 0)
|
||||
viewModel.hashtagStatusIDList.removeDuplicates()
|
||||
|
||||
let newPredicate = Toot.predicate(domain: activeMastodonAuthenticationBox.domain, ids: viewModel.hashtagStatusIDList)
|
||||
let newPredicate = Status.predicate(domain: activeMastodonAuthenticationBox.domain, ids: viewModel.hashtagStatusIDList)
|
||||
viewModel.timelinePredicate.send(newPredicate)
|
||||
}
|
||||
.store(in: &viewModel.disposeBag)
|
||||
|
|
|
@ -76,7 +76,7 @@ extension HashtagTimelineViewModel.LoadMiddleState {
|
|||
switch completion {
|
||||
case .failure(let error):
|
||||
// TODO: handle error
|
||||
os_log("%{public}s[%{public}ld], %{public}s: fetch toots failed. %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
||||
os_log("%{public}s[%{public}ld], %{public}s: fetch statuses failed. %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
||||
stateMachine.enter(Fail.self)
|
||||
case .finished:
|
||||
break
|
||||
|
@ -105,7 +105,7 @@ extension HashtagTimelineViewModel.LoadMiddleState {
|
|||
viewModel.needLoadMiddleIndex = nil
|
||||
}
|
||||
|
||||
let newPredicate = Toot.predicate(domain: activeMastodonAuthenticationBox.domain, ids: viewModel.hashtagStatusIDList)
|
||||
let newPredicate = Status.predicate(domain: activeMastodonAuthenticationBox.domain, ids: viewModel.hashtagStatusIDList)
|
||||
viewModel.timelinePredicate.send(newPredicate)
|
||||
|
||||
}
|
||||
|
|
|
@ -66,22 +66,22 @@ extension HashtagTimelineViewModel.LoadOldestState {
|
|||
// viewModel.homeTimelineNavigationBarState.receiveCompletion(completion: completion)
|
||||
switch completion {
|
||||
case .failure(let error):
|
||||
os_log("%{public}s[%{public}ld], %{public}s: fetch toots failed. %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
||||
os_log("%{public}s[%{public}ld], %{public}s: fetch statuses failed. %s", ((#file as NSString).lastPathComponent), #line, #function, error.localizedDescription)
|
||||
case .finished:
|
||||
// handle isFetchingLatestTimeline in fetch controller delegate
|
||||
break
|
||||
}
|
||||
} receiveValue: { response in
|
||||
let toots = response.value
|
||||
// enter no more state when no new toots
|
||||
if toots.isEmpty || (toots.count == 1 && toots[0].id == maxID) {
|
||||
let statuses = response.value
|
||||
// enter no more state when no new statuses
|
||||
if statuses.isEmpty || (statuses.count == 1 && statuses[0].id == maxID) {
|
||||
stateMachine.enter(NoMore.self)
|
||||
} else {
|
||||
stateMachine.enter(Idle.self)
|
||||
}
|
||||
let newStatusIDList = toots.map { $0.id }
|
||||
let newStatusIDList = statuses.map { $0.id }
|
||||
viewModel.hashtagStatusIDList.append(contentsOf: newStatusIDList)
|
||||
let newPredicate = Toot.predicate(domain: activeMastodonAuthenticationBox.domain, ids: viewModel.hashtagStatusIDList)
|
||||
let newPredicate = Status.predicate(domain: activeMastodonAuthenticationBox.domain, ids: viewModel.hashtagStatusIDList)
|
||||
viewModel.timelinePredicate.send(newPredicate)
|
||||
}
|
||||
.store(in: &viewModel.disposeBag)
|
||||
|
|
|
@ -24,7 +24,7 @@ final class HashtagTimelineViewModel: NSObject {
|
|||
|
||||
// input
|
||||
let context: AppContext
|
||||
let fetchedResultsController: NSFetchedResultsController<Toot>
|
||||
let fetchedResultsController: NSFetchedResultsController<Status>
|
||||
let isFetchingLatestTimeline = CurrentValueSubject<Bool, Never>(false)
|
||||
let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
|
||||
let hashtagEntity = CurrentValueSubject<Mastodon.Entity.Tag?, Never>(nil)
|
||||
|
@ -70,7 +70,7 @@ final class HashtagTimelineViewModel: NSObject {
|
|||
self.context = context
|
||||
self.hashTag = hashTag
|
||||
self.fetchedResultsController = {
|
||||
let fetchRequest = Toot.sortedFetchRequest
|
||||
let fetchRequest = Status.sortedFetchRequest
|
||||
fetchRequest.returnsObjectsAsFaults = false
|
||||
fetchRequest.fetchBatchSize = 20
|
||||
let controller = NSFetchedResultsController(
|
||||
|
|
|
@ -19,7 +19,7 @@ extension APIService {
|
|||
domain: String,
|
||||
sinceID: Mastodon.Entity.Status.ID? = nil,
|
||||
maxID: Mastodon.Entity.Status.ID? = nil,
|
||||
limit: Int = onceRequestTootMaxCount,
|
||||
limit: Int = onceRequestStatusMaxCount,
|
||||
local: Bool? = nil,
|
||||
hashtag: String,
|
||||
authorizationBox: AuthenticationService.MastodonAuthenticationBox
|
||||
|
|
Loading…
Reference in New Issue