mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 20:45:19 +00:00
Implement proper room leave notifications and improve UI
- Send leave notifications when users exit rooms - Update room member lists when peers leave rooms - Change current user icon from dot to person.fill - Handle room-specific leave messages via protocol - Maintain backwards compatibility for general peer disconnection
This commit is contained in:
@@ -132,6 +132,9 @@ class ChatViewModel: ObservableObject {
|
||||
joinedRooms.remove(room)
|
||||
saveJoinedRooms()
|
||||
|
||||
// Send leave notification to other peers
|
||||
meshService.sendRoomLeaveNotification(room)
|
||||
|
||||
// If we're currently in this room, exit to main chat
|
||||
if currentRoom == room {
|
||||
currentRoom = nil
|
||||
@@ -630,6 +633,17 @@ class ChatViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
extension ChatViewModel: BitchatDelegate {
|
||||
func didReceiveRoomLeave(_ room: String, from peerID: String) {
|
||||
// Remove peer from room members
|
||||
if roomMembers[room] != nil {
|
||||
roomMembers[room]?.remove(peerID)
|
||||
bitchatLog("Removed peer \(peerID) from room \(room) members", category: "room")
|
||||
|
||||
// Force UI update
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
||||
func didReceiveMessage(_ message: BitchatMessage) {
|
||||
bitchatLog("Received message from \(message.sender), room: \(message.room ?? "nil"), senderPeerID: \(message.senderPeerID ?? "nil")", category: "message")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user