From 6f6711458be9b712b9f87b03bd9dbf31e4101ed2 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 13 Nov 2023 12:53:47 +0100 Subject: [PATCH 1/5] Make profile edit-able again --- Mastodon/Scene/Profile/ProfileViewModel.swift | 5 ++--- .../CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents | 5 ++--- .../Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Mastodon/Scene/Profile/ProfileViewModel.swift b/Mastodon/Scene/Profile/ProfileViewModel.swift index 012ebf61b..630205371 100644 --- a/Mastodon/Scene/Profile/ProfileViewModel.swift +++ b/Mastodon/Scene/Profile/ProfileViewModel.swift @@ -178,12 +178,11 @@ class ProfileViewModel: NSObject { // fetch profile info before edit func fetchEditProfileInfo() -> AnyPublisher, Error> { - guard let me = me, - let mastodonAuthentication = me.mastodonAuthentication - else { + guard let me else { return Fail(error: APIService.APIError.implicit(.authenticationMissing)).eraseToAnyPublisher() } + let mastodonAuthentication = authContext.mastodonAuthenticationBox.authentication let authorization = Mastodon.API.OAuth.Authorization(accessToken: mastodonAuthentication.userAccessToken) return context.apiService.accountVerifyCredentials(domain: me.domain, authorization: authorization) } diff --git a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents index c5bbd1485..ee9d4b157 100644 --- a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents +++ b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -78,7 +78,7 @@ - + @@ -116,7 +116,6 @@ - diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift index 83f94fd22..da066c576 100644 --- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift +++ b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift @@ -63,7 +63,6 @@ final public class MastodonUser: NSManagedObject { // one-to-one relationship @NSManaged public private(set) var pinnedStatus: Status? - @NSManaged public private(set) var mastodonAuthentication: MastodonAuthenticationLegacy? // one-to-many relationship @NSManaged public private(set) var statuses: Set From f45aba91dc780673ac8764b2d1d4b335d8c86a25 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 13 Nov 2023 14:15:31 +0100 Subject: [PATCH 2/5] Fix crash when reordering rows containerStackView.isLayoutMarginsRelativeArrangement lead to an endless loop, so this is more of a quickfix (Honestly? No idea if it works, but it doesn't crash anymore). I changed the leading/trailing to match `contentView.layoutMarginsGuide` --- .../Cell/ProfileFieldCollectionViewCell.swift | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift index 94a7c1fa7..a314983a7 100644 --- a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift +++ b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift @@ -57,25 +57,19 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell { checkmark.isAccessibilityElement = true checkmark.accessibilityTraits = .none keyMetaLabel.accessibilityTraits = .none + keyMetaLabel.linkDelegate = self + valueMetaLabel.linkDelegate = self + // containerStackView: V - [ metaContainer | plainContainer ] let containerStackView = UIStackView() - containerStackView.axis = .vertical - - contentView.preservesSuperviewLayoutMargins = true - containerStackView.preservesSuperviewLayoutMargins = true - containerStackView.isLayoutMarginsRelativeArrangement = true containerStackView.translatesAutoresizingMaskIntoConstraints = false + containerStackView.axis = .vertical + containerStackView.preservesSuperviewLayoutMargins = true + contentView.addSubview(containerStackView) - NSLayoutConstraint.activate([ - containerStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8), - containerStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - contentView.trailingAnchor.constraint(equalTo: containerStackView.trailingAnchor), - contentView.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor, constant: 8), - checkmark.heightAnchor.constraint(equalToConstant: 22), - checkmark.widthAnchor.constraint(equalTo: checkmark.heightAnchor), - ]) - + contentView.preservesSuperviewLayoutMargins = true + // metaContainer: h - [ keyValueContainer | checkmark ] let metaContainer = UIStackView() metaContainer.axis = .horizontal @@ -95,8 +89,14 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell { metaContainer.addArrangedSubview(keyValueContainer) metaContainer.addArrangedSubview(checkmark) - keyMetaLabel.linkDelegate = self - valueMetaLabel.linkDelegate = self + NSLayoutConstraint.activate([ + containerStackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 11), + containerStackView.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor), + containerStackView.trailingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor), + contentView.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor, constant: 11), + checkmark.heightAnchor.constraint(equalToConstant: 22), + checkmark.widthAnchor.constraint(equalTo: checkmark.heightAnchor), + ]) isAccessibilityElement = true } From c6df361e4f978f6e10ac403ca449fa2117652684 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 13 Nov 2023 14:15:40 +0100 Subject: [PATCH 3/5] Do main-q stuff on main-q --- .../Scene/Profile/About/ProfileAboutViewModel+Diffable.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift index 5f37f90c1..7c69c9669 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewModel+Diffable.swift @@ -66,6 +66,7 @@ extension ProfileAboutViewModel { $emojiMeta.removeDuplicates() ) .throttle(for: 0.3, scheduler: DispatchQueue.main, latest: true) + .receive(on: DispatchQueue.main) .sink { [weak self] isEditing, createdAt, fields, emojiMeta in guard let self = self else { return } guard let diffableDataSource = self.diffableDataSource else { return } From d4c97d3da0434b333ba3899f3b5f2b5201e74e45 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 13 Nov 2023 14:19:06 +0100 Subject: [PATCH 4/5] Restore authentication We still need this legacy-authentication for migration :facepalm: --- .../CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents | 3 ++- .../Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents index ee9d4b157..385be91f7 100644 --- a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents +++ b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents @@ -78,7 +78,7 @@ - + @@ -116,6 +116,7 @@ + diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift index da066c576..83f94fd22 100644 --- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift +++ b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift @@ -63,6 +63,7 @@ final public class MastodonUser: NSManagedObject { // one-to-one relationship @NSManaged public private(set) var pinnedStatus: Status? + @NSManaged public private(set) var mastodonAuthentication: MastodonAuthenticationLegacy? // one-to-many relationship @NSManaged public private(set) var statuses: Set From 5b0cf175145debd440b9354f2e4629c2fbf0a8af Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 13 Nov 2023 14:58:29 +0100 Subject: [PATCH 5/5] Reset macOS-version --- .../CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents index 385be91f7..c5bbd1485 100644 --- a/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents +++ b/MastodonSDK/Sources/CoreDataStack/CoreData.xcdatamodeld/CoreData 9.xcdatamodel/contents @@ -1,5 +1,5 @@ - +