fix: profile fields cannot display issue. Fix race condition in edit fields workflow

This commit is contained in:
CMK 2022-06-14 13:44:32 +08:00
parent 765a6bc591
commit b0027ebcf6
4 changed files with 8 additions and 86 deletions

View File

@ -64,13 +64,8 @@ final class ProfileAboutViewModel {
guard let self = self else { return }
guard let account = account else { return }
self.profileInfo.fields = account.source?.fields?.compactMap { field in
ProfileFieldItem.FieldValue(
name: field.name,
value: field.value,
emojiMeta: emojiMeta
)
} ?? []
// update profileInfo will occurs race condition issue
// bind user.fields to profileInfo to avoid it
self.profileInfoEditing.fields = account.source?.fields?.compactMap { field in
ProfileFieldItem.FieldValue(

View File

@ -305,7 +305,10 @@ extension ProfileViewController {
}
// about
let aboutViewModel = profilePagingViewController.viewModel.profileAboutViewController.viewModel!
let aboutViewModel = viewModel.profileAboutViewModel
viewModel.$user
.assign(to: \.user, on: aboutViewModel)
.store(in: &disposeBag)
viewModel.$isEditing
.assign(to: \.isEditing, on: aboutViewModel)
.store(in: &disposeBag)

View File

@ -163,7 +163,7 @@ class ProfileViewModel: NSObject {
} // end Task
}
.store(in: &disposeBag)
//
let isBlockingOrBlocked = Publishers.CombineLatest(
relationshipViewModel.$isBlocking,
relationshipViewModel.$isBlockingBy

View File

@ -363,82 +363,6 @@ extension MastodonUser: AutoGenerateProperty {
// sourcery:end
}
//extension MastodonUser {
// public struct Property {
// public let identifier: String
// public let domain: String
//
// public let id: String
// public let acct: String
// public let username: String
// public let displayName: String
// public let avatar: String
// public let avatarStatic: String?
// public let header: String
// public let headerStatic: String?
// public let note: String?
// public let url: String?
// public let emojisData: Data?
// public let fieldsData: Data?
// public let statusesCount: Int
// public let followingCount: Int
// public let followersCount: Int
// public let locked: Bool
// public let bot: Bool?
// public let suspended: Bool?
//
// public let createdAt: Date
// public let networkDate: Date
//
// public init(
// id: String,
// domain: String,
// acct: String,
// username: String,
// displayName: String,
// avatar: String,
// avatarStatic: String?,
// header: String,
// headerStatic: String?,
// note: String?,
// url: String?,
// emojisData: Data?,
// fieldsData: Data?,
// statusesCount: Int,
// followingCount: Int,
// followersCount: Int,
// locked: Bool,
// bot: Bool?,
// suspended: Bool?,
// createdAt: Date,
// networkDate: Date
// ) {
// self.identifier = id + "@" + domain
// self.domain = domain
// self.id = id
// self.acct = acct
// self.username = username
// self.displayName = displayName
// self.avatar = avatar
// self.avatarStatic = avatarStatic
// self.header = header
// self.headerStatic = headerStatic
// self.note = note
// self.url = url
// self.emojisData = emojisData
// self.fieldsData = fieldsData
// self.statusesCount = statusesCount
// self.followingCount = followingCount
// self.followersCount = followersCount
// self.locked = locked
// self.bot = bot
// self.suspended = suspended
// self.createdAt = createdAt
// self.networkDate = networkDate
// }
// }
//}
// MARK: - AutoUpdatableObject
extension MastodonUser: AutoUpdatableObject {
// sourcery:inline:MastodonUser.AutoUpdatableObject