chore: rename Toot -> Status

This commit is contained in:
CMK 2021-04-02 19:40:15 +08:00
parent 412a7dc508
commit 28cfe96171
8 changed files with 20 additions and 20 deletions

View File

@ -14,11 +14,11 @@ import CoreDataStack
// MARK: - StatusProvider // MARK: - StatusProvider
extension HashtagTimelineViewController: StatusProvider { extension HashtagTimelineViewController: StatusProvider {
func toot() -> Future<Toot?, Never> { func status() -> Future<Status?, Never> {
return Future { promise in promise(.success(nil)) } 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 return Future { promise in
guard let diffableDataSource = self.viewModel.diffableDataSource else { guard let diffableDataSource = self.viewModel.diffableDataSource else {
assertionFailure() assertionFailure()
@ -36,7 +36,7 @@ extension HashtagTimelineViewController: StatusProvider {
let managedObjectContext = self.viewModel.context.managedObjectContext let managedObjectContext = self.viewModel.context.managedObjectContext
managedObjectContext.perform { managedObjectContext.perform {
let timelineIndex = managedObjectContext.object(with: objectID) as? HomeTimelineIndex let timelineIndex = managedObjectContext.object(with: objectID) as? HomeTimelineIndex
promise(.success(timelineIndex?.toot)) promise(.success(timelineIndex?.status))
} }
default: default:
promise(.success(nil)) 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)) } return Future { promise in promise(.success(nil)) }
} }

View File

@ -234,7 +234,7 @@ extension HashtagTimelineViewController: UITableViewDataSourcePrefetching {
// MARK: - TimelineMiddleLoaderTableViewCellDelegate // MARK: - TimelineMiddleLoaderTableViewCellDelegate
extension HashtagTimelineViewController: 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 { guard let upperTimelineIndexObjectID = timelineIndexobjectID else {
return return
} }

View File

@ -56,13 +56,13 @@ extension HashtagTimelineViewModel: NSFetchedResultsControllerDelegate {
let snapshot = snapshot as NSDiffableDataSourceSnapshot<Int, NSManagedObjectID> let snapshot = snapshot as NSDiffableDataSourceSnapshot<Int, NSManagedObjectID>
let statusItemList: [Item] = snapshot.itemIdentifiers.map { 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 = { let isStatusTextSensitive: Bool = {
guard let spoilerText = status.spoilerText, !spoilerText.isEmpty else { return false } guard let spoilerText = status.spoilerText, !spoilerText.isEmpty else { return false }
return true 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>() var newSnapshot = NSDiffableDataSourceSnapshot<StatusSection, Item>()

View File

@ -58,7 +58,7 @@ extension HashtagTimelineViewModel.LoadLatestState {
case .failure(let error): case .failure(let error):
// TODO: handle error // TODO: handle error
viewModel.isFetchingLatestTimeline.value = false 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: case .finished:
// handle isFetchingLatestTimeline in fetch controller delegate // handle isFetchingLatestTimeline in fetch controller delegate
break break
@ -83,7 +83,7 @@ extension HashtagTimelineViewModel.LoadLatestState {
viewModel.hashtagStatusIDList.insert(contentsOf: newStatusIDList, at: 0) viewModel.hashtagStatusIDList.insert(contentsOf: newStatusIDList, at: 0)
viewModel.hashtagStatusIDList.removeDuplicates() 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) viewModel.timelinePredicate.send(newPredicate)
} }
.store(in: &viewModel.disposeBag) .store(in: &viewModel.disposeBag)

View File

@ -76,7 +76,7 @@ extension HashtagTimelineViewModel.LoadMiddleState {
switch completion { switch completion {
case .failure(let error): case .failure(let error):
// TODO: handle 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) stateMachine.enter(Fail.self)
case .finished: case .finished:
break break
@ -105,7 +105,7 @@ extension HashtagTimelineViewModel.LoadMiddleState {
viewModel.needLoadMiddleIndex = nil 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) viewModel.timelinePredicate.send(newPredicate)
} }

View File

@ -66,22 +66,22 @@ extension HashtagTimelineViewModel.LoadOldestState {
// viewModel.homeTimelineNavigationBarState.receiveCompletion(completion: completion) // viewModel.homeTimelineNavigationBarState.receiveCompletion(completion: completion)
switch completion { switch completion {
case .failure(let error): 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: case .finished:
// handle isFetchingLatestTimeline in fetch controller delegate // handle isFetchingLatestTimeline in fetch controller delegate
break break
} }
} receiveValue: { response in } receiveValue: { response in
let toots = response.value let statuses = response.value
// enter no more state when no new toots // enter no more state when no new statuses
if toots.isEmpty || (toots.count == 1 && toots[0].id == maxID) { if statuses.isEmpty || (statuses.count == 1 && statuses[0].id == maxID) {
stateMachine.enter(NoMore.self) stateMachine.enter(NoMore.self)
} else { } else {
stateMachine.enter(Idle.self) stateMachine.enter(Idle.self)
} }
let newStatusIDList = toots.map { $0.id } let newStatusIDList = statuses.map { $0.id }
viewModel.hashtagStatusIDList.append(contentsOf: newStatusIDList) 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) viewModel.timelinePredicate.send(newPredicate)
} }
.store(in: &viewModel.disposeBag) .store(in: &viewModel.disposeBag)

View File

@ -24,7 +24,7 @@ final class HashtagTimelineViewModel: NSObject {
// input // input
let context: AppContext let context: AppContext
let fetchedResultsController: NSFetchedResultsController<Toot> let fetchedResultsController: NSFetchedResultsController<Status>
let isFetchingLatestTimeline = CurrentValueSubject<Bool, Never>(false) let isFetchingLatestTimeline = CurrentValueSubject<Bool, Never>(false)
let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil) let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
let hashtagEntity = CurrentValueSubject<Mastodon.Entity.Tag?, Never>(nil) let hashtagEntity = CurrentValueSubject<Mastodon.Entity.Tag?, Never>(nil)
@ -70,7 +70,7 @@ final class HashtagTimelineViewModel: NSObject {
self.context = context self.context = context
self.hashTag = hashTag self.hashTag = hashTag
self.fetchedResultsController = { self.fetchedResultsController = {
let fetchRequest = Toot.sortedFetchRequest let fetchRequest = Status.sortedFetchRequest
fetchRequest.returnsObjectsAsFaults = false fetchRequest.returnsObjectsAsFaults = false
fetchRequest.fetchBatchSize = 20 fetchRequest.fetchBatchSize = 20
let controller = NSFetchedResultsController( let controller = NSFetchedResultsController(

View File

@ -19,7 +19,7 @@ extension APIService {
domain: String, domain: String,
sinceID: Mastodon.Entity.Status.ID? = nil, sinceID: Mastodon.Entity.Status.ID? = nil,
maxID: Mastodon.Entity.Status.ID? = nil, maxID: Mastodon.Entity.Status.ID? = nil,
limit: Int = onceRequestTootMaxCount, limit: Int = onceRequestStatusMaxCount,
local: Bool? = nil, local: Bool? = nil,
hashtag: String, hashtag: String,
authorizationBox: AuthenticationService.MastodonAuthenticationBox authorizationBox: AuthenticationService.MastodonAuthenticationBox