PeerID 22/n: PrivateChatManager (#800)

* PrivateChatManager: functions to use `PeerID`

* PrivateChatManager: properties to use `PeerID`
This commit is contained in:
Islam
2025-10-14 12:30:18 +02:00
committed by GitHub
parent ad4103bacc
commit 23249f3e41
6 changed files with 150 additions and 133 deletions
+5 -5
View File
@@ -531,7 +531,7 @@ struct ContentView: View {
}
.onChange(of: viewModel.privateChats) { _ in
if let peerID = privatePeer,
let messages = viewModel.privateChats[peerID],
let messages = viewModel.privateChats[PeerID(str: peerID)],
!messages.isEmpty {
// If the newest private message is from me, always scroll
let lastMsg = messages.last!
@@ -663,7 +663,7 @@ struct ContentView: View {
(["/w"], nil, "see who's online")
]
let isGeoPublic: Bool = { if case .location = locationManager.selectedChannel { return true }; return false }()
let isGeoDM: Bool = (viewModel.selectedPrivateChatPeer?.hasPrefix("nostr_") == true)
let isGeoDM = viewModel.selectedPrivateChatPeer?.isGeoDM == true
let favInfo: [(commands: [String], syntax: String?, description: String)] = [
(["/fav"], "<nickname>", "add to favorites"),
(["/unfav"], "<nickname>", "remove from favorites")
@@ -747,7 +747,7 @@ struct ContentView: View {
if case .location = locationManager.selectedChannel { return true }
return false
}()
let isGeoDM: Bool = (viewModel.selectedPrivateChatPeer?.hasPrefix("nostr_") == true)
let isGeoDM = viewModel.selectedPrivateChatPeer?.isGeoDM == true
var commandDescriptions = [
("/block", String(localized: "content.commands.block", comment: "Description for /block command")),
("/clear", String(localized: "content.commands.clear", comment: "Description for /clear command")),
@@ -955,7 +955,7 @@ struct ContentView: View {
private var privateChatSheetView: some View {
VStack(spacing: 0) {
if let privatePeerID = viewModel.selectedPrivateChatPeer {
if let privatePeerID = viewModel.selectedPrivateChatPeer?.id {
let headerContext = makePrivateHeaderContext(for: privatePeerID)
HStack(spacing: 12) {
@@ -1021,7 +1021,7 @@ struct ContentView: View {
.background(backgroundColor)
}
messagesView(privatePeer: viewModel.selectedPrivateChatPeer, isAtBottom: $isAtBottomPrivate)
messagesView(privatePeer: viewModel.selectedPrivateChatPeer?.id, isAtBottom: $isAtBottomPrivate)
.background(backgroundColor)
.frame(maxWidth: .infinity, maxHeight: .infinity)
Divider()