Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions bitchat/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1282,14 +1282,12 @@ struct ContentView: View {
String(localized: "content.accessibility.open_unread_private_chat", comment: "Accessibility label for the unread private chat button")
)
}
// Notes icon (mesh only and when location is authorized), to the left of #mesh
if case .mesh = locationManager.selectedChannel, locationManager.permissionState == .authorized {
// Bookmark toggle and notes icon (geochats only): to the left of #geohash
// Notes post to Nostr (internet), so they belong in location channels, not #mesh
if case .location(let ch) = locationManager.selectedChannel {
// Notes icon - posts permanent notes to Nostr for this location
Button(action: {
// Kick a one-shot refresh and show the sheet immediately.
LocationChannelManager.shared.enableLocationChannels()
LocationChannelManager.shared.refreshChannels()
// If we already have a block geohash, pass it; otherwise wait in the sheet.
notesGeohash = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash
notesGeohash = ch.geohash
showLocationNotes = true
Comment on lines +1287 to 1291

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep location notes geohash at building precision

Selecting a non‑building location channel (e.g., city/province) and tapping the notes icon now passes the channel’s geohash straight into LocationNotesView (notesGeohash = ch.geohash). LocationNotesManager is explicitly scoped to 8‑character building geohashes (LocationNotesManager.swift lines 46–112 use Geohash.isValidBuildingGeohash to validate them), so shorter hashes produce warnings and the manager refuses later updates, leaving the sheet subscribing/posting under an invalid scope (often showing no notes). Before this change the button always used the building‑level geohash from availableChannels, so this regression affects anyone opening notes while on a higher‑level geo channel.

Useful? React with 👍 / 👎.

}) {
HStack(alignment: .center, spacing: 4) {
Expand All @@ -1304,10 +1302,6 @@ struct ContentView: View {
.accessibilityLabel(
String(localized: "content.accessibility.location_notes", comment: "Accessibility label for location notes button")
)
}

// Bookmark toggle (geochats): to the left of #geohash
if case .location(let ch) = locationManager.selectedChannel {
Button(action: { GeohashBookmarksStore.shared.toggle(ch.geohash) }) {
Image(systemName: GeohashBookmarksStore.shared.isBookmarked(ch.geohash) ? "bookmark.fill" : "bookmark")
.font(.bitchatSystem(size: 12))
Expand Down Expand Up @@ -1442,6 +1436,9 @@ struct ContentView: View {
LocationChannelManager.shared.endLiveRefresh()
}
.onChange(of: locationManager.availableChannels) { channels in
// Only auto-update notesGeohash if sheet is not already open
// (user may have selected a specific channel's geohash)
guard !showLocationNotes else { return }
if let current = channels.first(where: { $0.level == .building })?.geohash,
notesGeohash != current {
notesGeohash = current
Expand Down