mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 06:25:19 +00:00
Revert notes geohash selection back to block-level (precision 7); keep building level available but unused; update counter and sheet accordingly
This commit is contained in:
@@ -469,15 +469,14 @@ struct ContentView: View {
|
|||||||
guard (2...12).contains(gh.count), gh.allSatisfy({ allowed.contains($0) }) else { return }
|
guard (2...12).contains(gh.count), gh.allSatisfy({ allowed.contains($0) }) else { return }
|
||||||
func levelForLength(_ len: Int) -> GeohashChannelLevel {
|
func levelForLength(_ len: Int) -> GeohashChannelLevel {
|
||||||
switch len {
|
switch len {
|
||||||
case 0...2: return .region
|
case 0...2: return .region
|
||||||
case 3...4: return .province
|
case 3...4: return .province
|
||||||
case 5: return .city
|
case 5: return .city
|
||||||
case 6: return .neighborhood
|
case 6: return .neighborhood
|
||||||
case 7: return .block
|
case 7: return .block
|
||||||
case 8: return .building
|
default: return .block
|
||||||
default: return .building
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let level = levelForLength(gh.count)
|
let level = levelForLength(gh.count)
|
||||||
let ch = GeohashChannel(level: level, geohash: gh)
|
let ch = GeohashChannel(level: level, geohash: gh)
|
||||||
// Do not mark teleported when opening a geohash that is in our regional set.
|
// Do not mark teleported when opening a geohash that is in our regional set.
|
||||||
@@ -1181,7 +1180,7 @@ struct ContentView: View {
|
|||||||
LocationChannelManager.shared.enableLocationChannels()
|
LocationChannelManager.shared.enableLocationChannels()
|
||||||
LocationChannelManager.shared.refreshChannels()
|
LocationChannelManager.shared.refreshChannels()
|
||||||
// If we already have a block geohash, pass it; otherwise wait in the sheet.
|
// 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 = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash
|
||||||
showLocationNotes = true
|
showLocationNotes = true
|
||||||
}) {
|
}) {
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
@@ -1232,7 +1231,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.sheet(isPresented: $showLocationNotes) {
|
.sheet(isPresented: $showLocationNotes) {
|
||||||
Group {
|
Group {
|
||||||
if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash {
|
if let gh = notesGeohash ?? LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash {
|
||||||
LocationNotesView(geohash: gh)
|
LocationNotesView(geohash: gh)
|
||||||
.environmentObject(viewModel)
|
.environmentObject(viewModel)
|
||||||
} else {
|
} else {
|
||||||
@@ -1266,8 +1265,8 @@ struct ContentView: View {
|
|||||||
.background(backgroundColor)
|
.background(backgroundColor)
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
.onChange(of: locationManager.availableChannels) { channels in
|
.onChange(of: locationManager.availableChannels) { channels in
|
||||||
if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) {
|
if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) {
|
||||||
notesGeohash = building.geohash
|
notesGeohash = block.geohash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1479,8 +1478,8 @@ extension ContentView {
|
|||||||
private func updateNotesCounterSubscription() {
|
private func updateNotesCounterSubscription() {
|
||||||
switch locationManager.selectedChannel {
|
switch locationManager.selectedChannel {
|
||||||
case .mesh:
|
case .mesh:
|
||||||
if let building = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .building })?.geohash {
|
if let block = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash {
|
||||||
LocationNotesCounter.shared.subscribe(geohash: building)
|
LocationNotesCounter.shared.subscribe(geohash: block)
|
||||||
} else {
|
} else {
|
||||||
LocationNotesCounter.shared.cancel()
|
LocationNotesCounter.shared.cancel()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -381,8 +381,7 @@ struct LocationChannelsSheet: View {
|
|||||||
case 5: return .city
|
case 5: return .city
|
||||||
case 6: return .neighborhood
|
case 6: return .neighborhood
|
||||||
case 7: return .block
|
case 7: return .block
|
||||||
case 8: return .building
|
default: return .block
|
||||||
default: return .building
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -463,8 +462,6 @@ extension LocationChannelsSheet {
|
|||||||
switch level {
|
switch level {
|
||||||
case .region:
|
case .region:
|
||||||
return ""
|
return ""
|
||||||
case .building:
|
|
||||||
return ""
|
|
||||||
default:
|
default:
|
||||||
return "~"
|
return "~"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ struct LocationNotesSheet: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Group {
|
Group {
|
||||||
if let gh = notesGeohash ?? locationManager.availableChannels.first(where: { $0.level == .building })?.geohash {
|
if let gh = notesGeohash ?? locationManager.availableChannels.first(where: { $0.level == .block })?.geohash {
|
||||||
// Found block geohash: show notes view
|
// Found block geohash: show notes view
|
||||||
LocationNotesView(geohash: gh)
|
LocationNotesView(geohash: gh)
|
||||||
.environmentObject(viewModel)
|
.environmentObject(viewModel)
|
||||||
@@ -55,8 +55,8 @@ struct LocationNotesSheet: View {
|
|||||||
LocationChannelManager.shared.refreshChannels()
|
LocationChannelManager.shared.refreshChannels()
|
||||||
}
|
}
|
||||||
.onChange(of: locationManager.availableChannels) { channels in
|
.onChange(of: locationManager.availableChannels) { channels in
|
||||||
if notesGeohash == nil, let building = channels.first(where: { $0.level == .building }) {
|
if notesGeohash == nil, let block = channels.first(where: { $0.level == .block }) {
|
||||||
notesGeohash = building.geohash
|
notesGeohash = block.geohash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user