From 70c1fe222e8be7d1ca0d1b852d771e3586a95eb5 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:52:16 +0000 Subject: [PATCH 1/8] Update --- Mlem/API/Models/Person/APIPerson.swift | 12 ++--- Mlem/ContentView.swift | 10 +--- Mlem/Models/Content/User/UserModel.swift | 7 ++- Mlem/Views/Tabs/Profile/Profile View.swift | 52 ++++++++++++++++++- Mlem/Views/Tabs/Profile/UserView.swift | 36 +++---------- .../Views/Account/ProfileSettingsView.swift | 12 ++++- 6 files changed, 80 insertions(+), 49 deletions(-) diff --git a/Mlem/API/Models/Person/APIPerson.swift b/Mlem/API/Models/Person/APIPerson.swift index b719d34b6..282164d26 100644 --- a/Mlem/API/Models/Person/APIPerson.swift +++ b/Mlem/API/Models/Person/APIPerson.swift @@ -8,7 +8,7 @@ import Foundation // lemmy_db_schema::source::person::PersonSafe -struct APIPerson: Decodable, Identifiable, Hashable { +struct APIPerson: Decodable, Identifiable, Hashable, Equatable { let id: Int let name: String var displayName: String? @@ -29,11 +29,11 @@ struct APIPerson: Decodable, Identifiable, Hashable { let instanceId: Int } -extension APIPerson: Equatable { - static func == (lhs: APIPerson, rhs: APIPerson) -> Bool { - lhs.actorId == rhs.actorId - } -} +// extension APIPerson: Equatable { +// static func == (lhs: APIPerson, rhs: APIPerson) -> Bool { +// lhs.actorId == rhs.actorId +// } +// } extension APIPerson { var avatarUrl: URL? { LemmyURL(string: avatar)?.url } diff --git a/Mlem/ContentView.swift b/Mlem/ContentView.swift index 564d22fcb..93ac1a95b 100644 --- a/Mlem/ContentView.swift +++ b/Mlem/ContentView.swift @@ -42,14 +42,6 @@ struct ContentView: View { var accessibilityFont: Bool { UIApplication.shared.preferredContentSizeCategory.isAccessibilityCategory } - var myUser: UserModel? { - if let person = siteInformation.myUserInfo?.localUserView.person { - return UserModel(from: person) - } else { - return nil - } - } - var body: some View { FancyTabBar(selection: $tabSelection, navigationSelection: $tabNavigation, dragUpGestureCallback: showAccountSwitcherDragCallback) { Group { @@ -75,7 +67,7 @@ struct ContentView: View { } } - ProfileView(user: myUser) + ProfileView() .fancyTabItem(tag: TabSelection.profile) { FancyTabBarLabel( tag: TabSelection.profile, diff --git a/Mlem/Models/Content/User/UserModel.swift b/Mlem/Models/Content/User/UserModel.swift index 74bccc689..c37fdc122 100644 --- a/Mlem/Models/Content/User/UserModel.swift +++ b/Mlem/Models/Content/User/UserModel.swift @@ -27,7 +27,7 @@ struct UserModel { // Text let name: String let displayName: String - let bio: String? + var bio: String? // Images let avatar: URL? @@ -214,5 +214,10 @@ extension UserModel: Hashable { hasher.combine(blocked) hasher.combine(postCount) hasher.combine(commentCount) + hasher.combine(displayName) + hasher.combine(bio) + hasher.combine(avatar) + hasher.combine(banner) + hasher.combine(matrixUserId) } } diff --git a/Mlem/Views/Tabs/Profile/Profile View.swift b/Mlem/Views/Tabs/Profile/Profile View.swift index 2cede85e9..546eddd5e 100644 --- a/Mlem/Views/Tabs/Profile/Profile View.swift +++ b/Mlem/Views/Tabs/Profile/Profile View.swift @@ -6,17 +6,27 @@ // import SwiftUI +import Dependencies -// Profile tab view struct ProfileView: View { // appstorage + @Dependency(\.siteInformation) var siteInformation @AppStorage("shouldShowUserHeaders") var shouldShowUserHeaders: Bool = true - let user: UserModel? + @State var user: UserModel? + + init() { + if let person = siteInformation.myUserInfo?.localUserView.person { + self._user = .init(wrappedValue: UserModel(from: person)) + } + } @StateObject private var profileTabNavigation: AnyNavigationPath = .init() @StateObject private var navigation: Navigation = .init() + @State var isPresentingAccountSwitcher: Bool = false + @State var isPresentingProfileEditor: Bool = false + var body: some View { ScrollViewReader { proxy in NavigationStack(path: $profileTabNavigation.path) { @@ -25,6 +35,37 @@ struct ProfileView: View { .handleLemmyViews() .environmentObject(profileTabNavigation) .tabBarNavigationEnabled(.profile, navigation) + .toolbar { + ToolbarItem(placement: .topBarLeading) { + Button("Switch Account", systemImage: Icons.switchUser) { + isPresentingAccountSwitcher = true + } + } + // TODO: 0.17 deprecation + if (siteInformation.version ?? .infinity) >= .init("0.18.0") { + ToolbarItem(placement: .secondaryAction) { + Button("Edit", systemImage: Icons.edit) { + isPresentingProfileEditor = true + } + } + } + } + .sheet(isPresented: $isPresentingAccountSwitcher) { + Form { + AccountListView() + } + } + .sheet(isPresented: $isPresentingProfileEditor) { + if let person = siteInformation.myUserInfo?.localUserView.person { + self.user = UserModel(from: person) + } else { + self.user = nil + } + } content: { + NavigationStack { + ProfileSettingsView(showCloseButton: true) + } + } } else { LoadingView(whatIsLoading: .profile) .fancyTabScrollCompatible() @@ -34,6 +75,13 @@ struct ProfileView: View { .environment(\.navigationPathWithRoutes, $profileTabNavigation.path) .environment(\.scrollViewProxy, proxy) .environment(\.navigation, navigation) + .onChange(of: siteInformation.myUserInfo?.localUserView.person) { newValue in + if let newValue { + self.user?.bio = newValue.bio + } else { + self.user = nil + } + } } } } diff --git a/Mlem/Views/Tabs/Profile/UserView.swift b/Mlem/Views/Tabs/Profile/UserView.swift index 889364f42..12ef98389 100644 --- a/Mlem/Views/Tabs/Profile/UserView.swift +++ b/Mlem/Views/Tabs/Profile/UserView.swift @@ -8,7 +8,6 @@ import Dependencies import SwiftUI -// swiftlint:disable type_body_length struct UserView: View { @Dependency(\.apiClient) var apiClient @Dependency(\.errorHandler) var errorHandler @@ -26,8 +25,6 @@ struct UserView: View { @State var selectedTab: UserViewTab = .overview @State var isLoadingContent: Bool = true - @State var isPresentingAccountSwitcher: Bool = false - @StateObject var privatePostTracker: PostTracker @StateObject var privateCommentTracker: CommentTracker = .init() @@ -149,25 +146,10 @@ struct UserView: View { confirmationMenuFunction: confirmationMenuFunction ) .toolbar { - ToolbarItem(placement: .topBarTrailing) { + ToolbarItemGroup(placement: .secondaryAction) { let functions = user.menuFunctions { user = $0 } - if functions.count == 1, let first = functions.first { - MenuButton(menuFunction: first, confirmDestructive: confirmDestructive) - } else { - Menu { - ForEach(functions) { item in - MenuButton(menuFunction: item, confirmDestructive: confirmDestructive) - } - } label: { - Label("Menu", systemImage: Icons.menuCircle) - } - } - } - if isOwnProfile { - ToolbarItem(placement: .topBarLeading) { - Button("Switch Account", systemImage: Icons.switchUser) { - isPresentingAccountSwitcher = true - } + ForEach(functions) { item in + MenuButton(menuFunction: item, confirmDestructive: confirmDestructive) } } } @@ -184,9 +166,9 @@ struct UserView: View { } } .refreshable { - await Task { + Task { await tryReloadUser() - }.value + } } .hoistNavigation { if navigationPath.isEmpty { @@ -206,13 +188,9 @@ struct UserView: View { } } .fancyTabScrollCompatible() + .navigationBarColor() .navigationTitle(user.displayName) .navigationBarTitleDisplayMode(.inline) - .sheet(isPresented: $isPresentingAccountSwitcher) { - Form { - AccountListView() - } - } } var flairs: some View { @@ -284,5 +262,3 @@ struct UserView: View { .padding(.horizontal, AppConstants.postAndCommentSpacing) } } - -// swiftlint:enable type_body_length diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift index c1c62e890..894b62d6a 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift @@ -17,6 +17,8 @@ struct ProfileSettingsView: View { @Dependency(\.apiClient) var apiClient: APIClient @Dependency(\.errorHandler) var errorHandler: ErrorHandler + @Environment(\.dismiss) var dismiss + @State var displayName: String @State var bio: String @@ -25,13 +27,16 @@ struct ProfileSettingsView: View { @State var hasEdited: UserSettingsEditState = .unedited - init() { + let showCloseButton: Bool + + init(showCloseButton: Bool = false) { @Dependency(\.siteInformation) var siteInformation: SiteInformationTracker let user = siteInformation.myUserInfo?.localUserView _displayName = State(wrappedValue: user?.person.displayName ?? "") _bio = State(wrappedValue: user?.person.bio ?? "") _avatarAttachmentModel = StateObject(wrappedValue: .init(url: user?.person.avatar ?? "")) _bannerAttachmentModel = StateObject(wrappedValue: .init(url: user?.person.banner ?? "")) + self.showCloseButton = showCloseButton } @ViewBuilder @@ -172,6 +177,7 @@ struct ProfileSettingsView: View { .scrollDismissesKeyboard(.interactively) .navigationTitle("My Profile") .navigationBarBackButtonHidden(hasEdited != .unedited) + .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .topBarLeading) { if hasEdited == .edited { @@ -184,6 +190,10 @@ struct ProfileSettingsView: View { bannerAttachmentModel.url = user.person.banner ?? "" } } + } else if showCloseButton { + Button("Close", systemImage: Icons.close) { + dismiss() + } } } ToolbarItem(placement: .topBarTrailing) { From 900ffb6a6e6bdf0241f336eb51704e50992d6697 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Thu, 18 Jan 2024 20:46:38 +0000 Subject: [PATCH 2/8] Update --- Mlem/Models/Content/User/UserModel.swift | 70 +++++++++++-------- Mlem/Views/Tabs/Profile/Profile View.swift | 25 +------ Mlem/Views/Tabs/Profile/UserView.swift | 7 ++ .../Tabs/Search/Results/UserResultView.swift | 2 +- 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Mlem/Models/Content/User/UserModel.swift b/Mlem/Models/Content/User/UserModel.swift index c37fdc122..b0740a50a 100644 --- a/Mlem/Models/Content/User/UserModel.swift +++ b/Mlem/Models/Content/User/UserModel.swift @@ -17,37 +17,37 @@ struct UserModel { @Dependency(\.notifier) var notifier @available(*, deprecated, message: "Use attributes of the UserModel directly instead.") - var person: APIPerson + var person: APIPerson! // Ids - let userId: Int - let instanceId: Int - let matrixUserId: String? + var userId: Int! + var instanceId: Int! + var matrixUserId: String? // Text - let name: String - let displayName: String + var name: String! + var displayName: String! var bio: String? // Images - let avatar: URL? - let banner: URL? + var avatar: URL? + var banner: URL? // State - let banned: Bool - let local: Bool - let deleted: Bool - let isBot: Bool - var blocked: Bool + var banned: Bool! + var local: Bool! + var deleted: Bool! + var isBot: Bool! + var blocked: Bool! // Dates - let creationDate: Date - let updatedDate: Date? - let banExpirationDate: Date? + var creationDate: Date! + var updatedDate: Date? + var banExpirationDate: Date? // URLs - let profileUrl: URL - let sharedInboxUrl: URL? + var profileUrl: URL! + var sharedInboxUrl: URL? // From APIPersonView var isAdmin: Bool? @@ -69,15 +69,28 @@ struct UserModel { /// Creates a UserModel from an GetPersonDetailsResponse /// - Parameter response: GetPersonDetailsResponse to create a UserModel representation of init(from response: GetPersonDetailsResponse) { - self.init(from: response.personView) - self.moderatedCommunities = response.moderates.map { CommunityModel(from: $0.community) } + self.update(with: response) } /// Creates a UserModel from an APIPersonView /// - Parameter apiPersonView: APIPersonView to create a UserModel representation of init(from personView: APIPersonView) { - self.init(from: personView.person) - + self.update(with: personView) + } + + /// Creates a UserModel from an APIPerson. Note that using this initialiser nullifies count values, since + /// those are only accessable from APIPersonView. + /// - Parameter apiPerson: APIPerson to create a UserModel representation of + init(from person: APIPerson) { + update(with: person) + } + + mutating func update(with response: GetPersonDetailsResponse) { + self.moderatedCommunities = response.moderates.map { CommunityModel(from: $0.community) } + self.update(with: response.personView) + } + + mutating func update(with personView: APIPersonView) { self.postCount = personView.counts.postCount self.commentCount = personView.counts.commentCount @@ -86,12 +99,11 @@ struct UserModel { if (siteInformation.version ?? .infinity) > .init("0.19.0") { self.isAdmin = personView.isAdmin } + + self.update(with: personView.person) } - /// Creates a UserModel from an APIPerson. Note that using this initialiser nullifies count values, since - /// those are only accessable from APIPersonView. - /// - Parameter apiPerson: APIPerson to create a UserModel representation of - init(from person: APIPerson) { + mutating func update(with person: APIPerson) { self.person = person self.userId = person.id @@ -121,7 +133,9 @@ struct UserModel { // Annoyingly, PersonView doesn't include whether the user is blocked so we can't // actually determine this without making extra requests... - self.blocked = false + if self.blocked == nil { + self.blocked = false + } } // Once we've done other model types we should stop this from relying on API types @@ -179,7 +193,7 @@ struct UserModel { var fullyQualifiedUsername: String? { if let host = self.profileUrl.host() { - return "\(name)@\(host)" + return "\(name!)@\(host)" } return nil } diff --git a/Mlem/Views/Tabs/Profile/Profile View.swift b/Mlem/Views/Tabs/Profile/Profile View.swift index 546eddd5e..e1d018ee9 100644 --- a/Mlem/Views/Tabs/Profile/Profile View.swift +++ b/Mlem/Views/Tabs/Profile/Profile View.swift @@ -12,14 +12,6 @@ struct ProfileView: View { // appstorage @Dependency(\.siteInformation) var siteInformation @AppStorage("shouldShowUserHeaders") var shouldShowUserHeaders: Bool = true - - @State var user: UserModel? - - init() { - if let person = siteInformation.myUserInfo?.localUserView.person { - self._user = .init(wrappedValue: UserModel(from: person)) - } - } @StateObject private var profileTabNavigation: AnyNavigationPath = .init() @StateObject private var navigation: Navigation = .init() @@ -30,8 +22,8 @@ struct ProfileView: View { var body: some View { ScrollViewReader { proxy in NavigationStack(path: $profileTabNavigation.path) { - if let user { - UserView(user: user) + if let person = siteInformation.myUserInfo?.localUserView.person { + UserView(user: UserModel(from: person)) .handleLemmyViews() .environmentObject(profileTabNavigation) .tabBarNavigationEnabled(.profile, navigation) @@ -56,12 +48,6 @@ struct ProfileView: View { } } .sheet(isPresented: $isPresentingProfileEditor) { - if let person = siteInformation.myUserInfo?.localUserView.person { - self.user = UserModel(from: person) - } else { - self.user = nil - } - } content: { NavigationStack { ProfileSettingsView(showCloseButton: true) } @@ -75,13 +61,6 @@ struct ProfileView: View { .environment(\.navigationPathWithRoutes, $profileTabNavigation.path) .environment(\.scrollViewProxy, proxy) .environment(\.navigation, navigation) - .onChange(of: siteInformation.myUserInfo?.localUserView.person) { newValue in - if let newValue { - self.user?.bio = newValue.bio - } else { - self.user = nil - } - } } } } diff --git a/Mlem/Views/Tabs/Profile/UserView.swift b/Mlem/Views/Tabs/Profile/UserView.swift index 12ef98389..e9d666381 100644 --- a/Mlem/Views/Tabs/Profile/UserView.swift +++ b/Mlem/Views/Tabs/Profile/UserView.swift @@ -170,6 +170,13 @@ struct UserView: View { await tryReloadUser() } } + .onChange(of: siteInformation.myUserInfo?.localUserView.person) { newValue in + if isOwnProfile { + if let newValue { + self.user.update(with: newValue) + } + } + } .hoistNavigation { if navigationPath.isEmpty { withAnimation { diff --git a/Mlem/Views/Tabs/Search/Results/UserResultView.swift b/Mlem/Views/Tabs/Search/Results/UserResultView.swift index b19a17292..fe8dcf71e 100644 --- a/Mlem/Views/Tabs/Search/Results/UserResultView.swift +++ b/Mlem/Views/Tabs/Search/Results/UserResultView.swift @@ -44,7 +44,7 @@ struct UserResultView: View { var title: String { if user.blocked { - return "\(user.displayName) ∙ Blocked" + return "\(user.displayName!) ∙ Blocked" } else { return user.displayName } From 80aabc540aed98e6cc9103b14bbaff1a36216f55 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Thu, 18 Jan 2024 20:53:27 +0000 Subject: [PATCH 3/8] Bug fix --- Mlem/Views/Tabs/Profile/Profile View.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Mlem/Views/Tabs/Profile/Profile View.swift b/Mlem/Views/Tabs/Profile/Profile View.swift index e1d018ee9..3cba0c0a1 100644 --- a/Mlem/Views/Tabs/Profile/Profile View.swift +++ b/Mlem/Views/Tabs/Profile/Profile View.swift @@ -14,7 +14,10 @@ struct ProfileView: View { @AppStorage("shouldShowUserHeaders") var shouldShowUserHeaders: Bool = true @StateObject private var profileTabNavigation: AnyNavigationPath = .init() + @StateObject private var editorSheetNavigation: AnyNavigationPath = .init() + @StateObject private var navigation: Navigation = .init() + @StateObject private var sheetNavigation: Navigation = .init() @State var isPresentingAccountSwitcher: Bool = false @State var isPresentingProfileEditor: Bool = false @@ -48,9 +51,14 @@ struct ProfileView: View { } } .sheet(isPresented: $isPresentingProfileEditor) { - NavigationStack { + NavigationStack(path: $editorSheetNavigation.path) { ProfileSettingsView(showCloseButton: true) + .handleLemmyViews() + .environmentObject(editorSheetNavigation) } + .handleLemmyLinkResolution(navigationPath: .constant(editorSheetNavigation)) + .environment(\.navigationPathWithRoutes, $editorSheetNavigation.path) + .environment(\.navigation, sheetNavigation) } } else { LoadingView(whatIsLoading: .profile) From a1242fd211f8595603d4ccbc7d4e08f922d320fa Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Thu, 18 Jan 2024 20:58:19 +0000 Subject: [PATCH 4/8] Disable interactive dismiss if you edited something --- .../Tabs/Settings/Components/Views/Account/MatrixLinkView.swift | 1 + .../Settings/Components/Views/Account/ProfileSettingsView.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Account/MatrixLinkView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Account/MatrixLinkView.swift index dec3f9ad4..48959c251 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Account/MatrixLinkView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Account/MatrixLinkView.swift @@ -116,5 +116,6 @@ struct MatrixLinkView: View { } } .hoistNavigation() + .interactiveDismissDisabled(hasEdited != .unedited) } } diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift index 894b62d6a..61629b77c 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Account/ProfileSettingsView.swift @@ -232,5 +232,6 @@ struct ProfileSettingsView: View { } .fancyTabScrollCompatible() .hoistNavigation() + .interactiveDismissDisabled(hasEdited != .unedited) } } From 83b641a1bca548cec8991895f62dcf4e4d651f4c Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Thu, 18 Jan 2024 21:05:00 +0000 Subject: [PATCH 5/8] bug fix --- Mlem/Views/Tabs/Profile/UserFeedView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mlem/Views/Tabs/Profile/UserFeedView.swift b/Mlem/Views/Tabs/Profile/UserFeedView.swift index 1bf7303c3..97a5e60bd 100644 --- a/Mlem/Views/Tabs/Profile/UserFeedView.swift +++ b/Mlem/Views/Tabs/Profile/UserFeedView.swift @@ -42,7 +42,7 @@ struct UserFeedView: View { switch selectedTab { case .communities: Label( - "\(user.displayName) moderates \(communityTracker.items.count) communities.", + "\(user.displayName) moderates ^[\(communityTracker.items.count) communities](inflect: true).", systemImage: Icons.moderationFill ) .foregroundStyle(.secondary) From 8ba28b19fbd77b6cad92010c0fee83119d95ba4b Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Fri, 19 Jan 2024 21:43:51 +0000 Subject: [PATCH 6/8] Update APIPerson.swift --- Mlem/API/Models/Person/APIPerson.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Mlem/API/Models/Person/APIPerson.swift b/Mlem/API/Models/Person/APIPerson.swift index 282164d26..278f2c02c 100644 --- a/Mlem/API/Models/Person/APIPerson.swift +++ b/Mlem/API/Models/Person/APIPerson.swift @@ -29,12 +29,6 @@ struct APIPerson: Decodable, Identifiable, Hashable, Equatable { let instanceId: Int } -// extension APIPerson: Equatable { -// static func == (lhs: APIPerson, rhs: APIPerson) -> Bool { -// lhs.actorId == rhs.actorId -// } -// } - extension APIPerson { var avatarUrl: URL? { LemmyURL(string: avatar)?.url } var bannerUrl: URL? { LemmyURL(string: banner)?.url } From cf322414ed78dcc07a783f8db79bc818b622ad01 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Fri, 26 Jan 2024 20:34:28 +0000 Subject: [PATCH 7/8] Update Profile View.swift --- Mlem/Views/Tabs/Profile/Profile View.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Mlem/Views/Tabs/Profile/Profile View.swift b/Mlem/Views/Tabs/Profile/Profile View.swift index 43b33bcad..49385d6b9 100644 --- a/Mlem/Views/Tabs/Profile/Profile View.swift +++ b/Mlem/Views/Tabs/Profile/Profile View.swift @@ -13,8 +13,6 @@ struct ProfileView: View { @Dependency(\.siteInformation) var siteInformation @AppStorage("shouldShowUserHeaders") var shouldShowUserHeaders: Bool = true - let user: UserModel? - @StateObject private var profileTabNavigation: AnyNavigationPath = .init() @StateObject private var editorSheetNavigation: AnyNavigationPath = .init() From c3b7ff4d31be4511b0297838e45e99547163942c Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:07:19 +0000 Subject: [PATCH 8/8] Fix bugs --- Mlem/ContentView.swift | 5 +++-- Mlem/Models/Content/Instance/InstanceModel.swift | 3 ++- Mlem/Models/Content/User/UserModel.swift | 2 -- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Mlem/ContentView.swift b/Mlem/ContentView.swift index 52d1865d5..8e0326a1d 100644 --- a/Mlem/ContentView.swift +++ b/Mlem/ContentView.swift @@ -77,8 +77,9 @@ struct ContentView: View { activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol, remoteSymbolUrl: appState.profileTabRemoteSymbolUrl ) - .simultaneousGesture(accountSwitchLongPress) - } + ) + .simultaneousGesture(accountSwitchLongPress) + } SearchRoot() .fancyTabItem(tag: TabSelection.search) { diff --git a/Mlem/Models/Content/Instance/InstanceModel.swift b/Mlem/Models/Content/Instance/InstanceModel.swift index 10ca52888..ca396483d 100644 --- a/Mlem/Models/Content/Instance/InstanceModel.swift +++ b/Mlem/Models/Content/Instance/InstanceModel.swift @@ -27,7 +27,8 @@ struct InstanceModel { mutating func update(with response: SiteResponse) { self.administrators = response.admins.map { - var user = UserModel(from: $0, usesExternalData: true) + var user = UserModel(from: $0) + user.usesExternalData = true user.isAdmin = true return user } diff --git a/Mlem/Models/Content/User/UserModel.swift b/Mlem/Models/Content/User/UserModel.swift index c5ecd9c4f..142dfd4f3 100644 --- a/Mlem/Models/Content/User/UserModel.swift +++ b/Mlem/Models/Content/User/UserModel.swift @@ -97,8 +97,6 @@ struct UserModel { mutating func update(with personView: APIPersonView) { self.postCount = personView.counts.postCount self.commentCount = personView.counts.commentCount - - self.usesExternalData = usesExternalData // TODO: 0.18 Deprecation @Dependency(\.siteInformation) var siteInformation