mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 15:45:20 +00:00
UI: fix DM autoscroll IDs by using dm:<peer>|<id> for private chat item IDs and preserve anchors, ensuring scrollTo targets exist when opening/switching/new messages
This commit is contained in:
@@ -291,13 +291,17 @@ struct ContentView: View {
|
|||||||
// Build stable UI IDs with a context key to avoid ID collisions when switching channels
|
// Build stable UI IDs with a context key to avoid ID collisions when switching channels
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
let contextKey: String = {
|
let contextKey: String = {
|
||||||
|
if let peer = privatePeer { return "dm:\\(peer)" }
|
||||||
switch locationManager.selectedChannel {
|
switch locationManager.selectedChannel {
|
||||||
case .mesh: return "mesh"
|
case .mesh: return "mesh"
|
||||||
case .location(let ch): return "geo:\(ch.geohash)"
|
case .location(let ch): return "geo:\\(ch.geohash)"
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
#else
|
#else
|
||||||
let contextKey: String = "mesh"
|
let contextKey: String = {
|
||||||
|
if let peer = privatePeer { return "dm:\\(peer)" }
|
||||||
|
return "mesh"
|
||||||
|
}()
|
||||||
#endif
|
#endif
|
||||||
let items = windowedMessages.map { (uiID: "\(contextKey)|\($0.id)", message: $0) }
|
let items = windowedMessages.map { (uiID: "\(contextKey)|\($0.id)", message: $0) }
|
||||||
|
|
||||||
@@ -396,13 +400,17 @@ struct ContentView: View {
|
|||||||
let step = 200
|
let step = 200
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
let contextKey: String = {
|
let contextKey: String = {
|
||||||
|
if let peer = privatePeer { return "dm:\\(peer)" }
|
||||||
switch locationManager.selectedChannel {
|
switch locationManager.selectedChannel {
|
||||||
case .mesh: return "mesh"
|
case .mesh: return "mesh"
|
||||||
case .location(let ch): return "geo:\(ch.geohash)"
|
case .location(let ch): return "geo:\\(ch.geohash)"
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
#else
|
#else
|
||||||
let contextKey: String = "mesh"
|
let contextKey: String = {
|
||||||
|
if let peer = privatePeer { return "dm:\\(peer)" }
|
||||||
|
return "mesh"
|
||||||
|
}()
|
||||||
#endif
|
#endif
|
||||||
let preserveID = "\(contextKey)|\(message.id)"
|
let preserveID = "\(contextKey)|\(message.id)"
|
||||||
if let peer = privatePeer {
|
if let peer = privatePeer {
|
||||||
|
|||||||
Reference in New Issue
Block a user