Skip to content

Commit

Permalink
Merge pull request #1098 from planetary-social/bugfix/edit-profile-mac
Browse files Browse the repository at this point in the history
Potential fix for edit profile issue on Mac
  • Loading branch information
joshuatbrown authored Apr 29, 2024
2 parents eeb2a6f + 73d61b3 commit 4e39216
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added "Send To Nos" private reporting to protect user privacy
- Discover tab now features authors in a variety of categories.
- Fixed an issue on Mac where the Edit Profile screen did not appear in some cases.
- Fixed an issue where registering a NIP-05 username field could fail silently.
- Fixed an issue where users named with valid urls were unable to be mentioned correctly.
- Fixed an issue where pasting an npub while composing a note created an invalid mention.
Expand Down
2 changes: 0 additions & 2 deletions Nos/Service/CurrentUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ enum CurrentUserError: Error {

var subscriptions = SubscriptionCancellables()

var editing = false

var onboardingRelays: [Relay] = []

// TODO: prevent this from being accessed from contexts other than the view context. Or maybe just get rid of it.
Expand Down
3 changes: 3 additions & 0 deletions Nos/Views/Discover/DiscoverTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ struct DiscoverTab: View {
.navigationDestination(for: Author.self) { author in
ProfileView(author: author)
}
.navigationDestination(for: EditProfileDestination.self) { destination in
ProfileEditView(author: destination.profile)
}
.navigationBarTitle(String(localized: .localizable.discover), displayMode: .inline)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(Color.cardBgBottom, for: .navigationBar)
Expand Down
13 changes: 4 additions & 9 deletions Nos/Views/Home/HomeTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ struct HomeTab: View {
RepliesView(note: note)
}
.navigationDestination(for: Author.self) { author in
if router.currentPath.wrappedValue.count == 1 {
ProfileView(author: author)
} else {
if author == currentUser.author, currentUser.editing {
ProfileEditView(author: author)
} else {
ProfileView(author: author)
}
}
ProfileView(author: author)
}
.navigationDestination(for: EditProfileDestination.self) { destination in
ProfileEditView(author: destination.profile)
}
.navigationDestination(for: ReplyToNavigationDestination.self) { destination in
RepliesView(note: destination.note, showKeyboard: true)
Expand Down
3 changes: 3 additions & 0 deletions Nos/Views/NotificationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ struct NotificationsView: View {
.navigationDestination(for: Author.self) { author in
ProfileView(author: author)
}
.navigationDestination(for: EditProfileDestination.self) { destination in
ProfileEditView(author: destination.profile)
}
.refreshable {
await subscribeToNewEvents()
}
Expand Down
9 changes: 4 additions & 5 deletions Nos/Views/Profile/ProfileTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ struct ProfileTab: View {
ProfileView(author: author, addDoubleTapToPop: true)
.navigationBarItems(leading: SideMenuButton())
.navigationDestination(for: Author.self) { profile in
if profile == currentUser.author, currentUser.editing {
ProfileEditView(author: author)
} else {
ProfileView(author: profile)
}
ProfileView(author: profile)
}
.navigationDestination(for: EditProfileDestination.self) { destination in
ProfileEditView(author: destination.profile)
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions Nos/Views/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ struct ProfileView: View {
.navigationDestination(for: RelaysDestination.self) { destination in
RelayView(author: destination.author, editable: false)
}
.navigationDestination(for: EditProfileDestination.self) { destination in
ProfileEditView(author: destination.profile)
}
.navigationBarItems(
trailing:
HStack {
Expand All @@ -132,8 +135,7 @@ struct ProfileView: View {
if isShowingLoggedInUser {
Button(
action: {
currentUser.editing = true
router.push(author)
router.push(EditProfileDestination(profile: author))
},
label: {
Text(.localizable.editProfile)
Expand Down
7 changes: 4 additions & 3 deletions Nos/Views/ProfileEdit/ProfileEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import Dependencies
import Logger
import SwiftUI

struct EditProfileDestination: Hashable {
let profile: Author
}

struct ProfileEditView: View {

@EnvironmentObject private var router: Router
Expand Down Expand Up @@ -162,9 +166,6 @@ struct ProfileEditView: View {
.task {
populateTextFields()
}
.onDisappear {
currentUser.editing = false
}
}

func populateTextFields() {
Expand Down
12 changes: 5 additions & 7 deletions Nos/Views/SideMenuContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ struct SideMenuContent: View {
buttonImage: .editProfile
) {
if let author = currentUser.author {
currentUser.editing = true
router.push(author)
router.push(EditProfileDestination(profile: author))
}
}
.padding(.horizontal, 20)
Expand Down Expand Up @@ -111,11 +110,10 @@ struct SideMenuContent: View {
}
}
.navigationDestination(for: Author.self) { profile in
if profile == currentUser.author, currentUser.editing {
ProfileEditView(author: profile)
} else {
ProfileView(author: profile)
}
ProfileView(author: profile)
}
.navigationDestination(for: EditProfileDestination.self) { destination in
ProfileEditView(author: destination.profile)
}
}
}
Expand Down

0 comments on commit 4e39216

Please sign in to comment.