Compare commits
3 Commits
c02eb14cec
...
8e42d50cf6
Author | SHA1 | Date |
---|---|---|
Nathan Mattes | 8e42d50cf6 | |
Marcus Kida | ddb3211641 | |
Nathan Mattes | 409fade845 |
|
@ -105,9 +105,10 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
|
||||
guard let viewModel else { return }
|
||||
|
||||
let latestFeedRecords = viewModel.dataController.records.prefix(APIService.onceRequestStatusMaxCount)
|
||||
|
||||
Task {
|
||||
Task { @MainActor in
|
||||
let latestFeedRecords = viewModel.dataController.records.prefix(APIService.onceRequestStatusMaxCount)
|
||||
|
||||
let latestStatusIDs: [Status.ID] = latestFeedRecords.compactMap { record in
|
||||
return record.status?.reblog?.id ?? record.status?.id
|
||||
}
|
||||
|
@ -128,7 +129,7 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
)
|
||||
}
|
||||
|
||||
await enter(state: Idle.self)
|
||||
enter(state: Idle.self)
|
||||
viewModel.receiveLoadingStateCompletion(.finished)
|
||||
|
||||
// stop refresher if no new statuses
|
||||
|
@ -146,7 +147,7 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
for (i, record) in newRecords.enumerated() {
|
||||
if let index = oldRecords.firstIndex(where: { $0.status?.reblog?.id == record.id || $0.status?.id == record.id }) {
|
||||
oldRecords[index] = record
|
||||
if newRecords.count > index {
|
||||
if newRecords.count > i {
|
||||
newRecords.remove(at: i)
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ extension HomeTimelineViewModel.LoadLatestState {
|
|||
}
|
||||
|
||||
} catch {
|
||||
await enter(state: Idle.self)
|
||||
enter(state: Idle.self)
|
||||
viewModel.didLoadLatest.send()
|
||||
viewModel.receiveLoadingStateCompletion(.failure(error))
|
||||
}
|
||||
|
|
|
@ -51,30 +51,24 @@ final class ProfileHeaderViewModel {
|
|||
self.account = account
|
||||
self.me = me
|
||||
self.relationship = relationship
|
||||
|
||||
$accountForEdit
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] account in
|
||||
guard let self = self else { return }
|
||||
guard let account = account else { return }
|
||||
// banner
|
||||
self.profileInfo.header = nil
|
||||
self.profileInfoEditing.header = nil
|
||||
// avatar
|
||||
self.profileInfo.avatar = nil
|
||||
self.profileInfoEditing.avatar = nil
|
||||
// name
|
||||
let name = account.displayNameWithFallback
|
||||
self.profileInfo.name = name
|
||||
self.profileInfoEditing.name = name
|
||||
// bio
|
||||
let note = ProfileHeaderViewModel.normalize(note: account.note)
|
||||
self.profileInfo.note = note
|
||||
self.profileInfoEditing.note = note
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
}
|
||||
|
||||
public func setProfileInfo(accountForEdit: Mastodon.Entity.Account) {
|
||||
// banner
|
||||
profileInfo.header = nil
|
||||
profileInfoEditing.header = nil
|
||||
// avatar
|
||||
profileInfo.avatar = nil
|
||||
profileInfoEditing.avatar = nil
|
||||
|
||||
let name = account.displayNameWithFallback
|
||||
profileInfo.name = name
|
||||
profileInfoEditing.name = name
|
||||
// bio
|
||||
let note = ProfileHeaderViewModel.normalize(note: account.note)
|
||||
profileInfo.note = note
|
||||
profileInfoEditing.note = note
|
||||
}
|
||||
}
|
||||
|
||||
extension ProfileHeaderViewModel {
|
||||
|
|
|
@ -794,8 +794,9 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate {
|
|||
profileAboutViewModel.isEditing = true
|
||||
}
|
||||
} receiveValue: { [weak self] response in
|
||||
guard let self = self else { return }
|
||||
self.viewModel.accountForEdit = response.value
|
||||
guard let self else { return }
|
||||
|
||||
self.profileHeaderViewController.viewModel.setProfileInfo(accountForEdit: response.value)
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
} else if isEdited == false {
|
||||
|
|
Loading…
Reference in New Issue