Refactor room commands and improve UX

- Replace /list with /rooms showing all discovered rooms with join status
- Remove /discover command (merged into /rooms)
- Rename /favorite to /save for clarity
- Make room-specific commands (/transfer, /pass, /save) only appear in room context
- Remove voice notes from app info (feature doesn't exist)
- Remove Commands line from app info screen
- Show checkmark (✓) for joined rooms in /rooms output
This commit is contained in:
jack
2025-07-05 19:35:37 +02:00
parent 506c2bc7cb
commit 41c2899008
4 changed files with 72 additions and 92 deletions
+44 -68
View File
@@ -1445,25 +1445,54 @@ extension ChatViewModel: BitchatDelegate {
)
messages.append(systemMessage)
}
case "/list":
if joinedRooms.isEmpty {
case "/rooms":
// Discover all rooms (both joined and not joined)
var allRooms: Set<String> = Set()
// Add joined rooms
allRooms.formUnion(joinedRooms)
// Find rooms from messages we've seen
for msg in messages {
if let room = msg.room {
allRooms.insert(room)
}
}
// Also check room messages we've cached
for (room, _) in roomMessages {
allRooms.insert(room)
}
// Add password protected rooms we know about
allRooms.formUnion(passwordProtectedRooms)
if allRooms.isEmpty {
let systemMessage = BitchatMessage(
sender: "system",
content: "you haven't joined any rooms yet. use /create or /join to get started.",
content: "no rooms discovered yet. rooms appear as people use them.",
timestamp: Date(),
isRelay: false
)
messages.append(systemMessage)
} else {
let roomList = joinedRooms.sorted().map { room in
let isProtected = passwordProtectedRooms.contains(room) ? " 🔒" : ""
let isCreator = roomCreators[room] == meshService.myPeerID ? " (owner)" : ""
return "\(room)\(isProtected)\(isCreator)"
let roomList = allRooms.sorted().map { room in
var status = ""
if joinedRooms.contains(room) {
status += ""
}
if passwordProtectedRooms.contains(room) {
status += " 🔒"
}
if roomCreators[room] == meshService.myPeerID {
status += " (owner)"
}
return "\(room)\(status)"
}.joined(separator: "\n")
let systemMessage = BitchatMessage(
sender: "system",
content: "your rooms:\n\(roomList)",
content: "discovered rooms:\n\(roomList)\n\n✓ = joined",
timestamp: Date(),
isRelay: false
)
@@ -1492,59 +1521,6 @@ extension ChatViewModel: BitchatDelegate {
)
messages.append(systemMessage)
}
case "/discover":
// Discover public rooms
var publicRooms: [String] = []
var protectedRooms: [String] = []
// Find rooms from messages we've seen
for msg in messages {
if let room = msg.room {
if passwordProtectedRooms.contains(room) {
if !protectedRooms.contains(room) {
protectedRooms.append(room)
}
} else {
if !publicRooms.contains(room) {
publicRooms.append(room)
}
}
}
}
// Also check room messages we've cached
for (room, _) in roomMessages {
if passwordProtectedRooms.contains(room) {
if !protectedRooms.contains(room) {
protectedRooms.append(room)
}
} else {
if !publicRooms.contains(room) {
publicRooms.append(room)
}
}
}
var discoveryMessage = ""
if publicRooms.isEmpty && protectedRooms.isEmpty {
discoveryMessage = "no rooms discovered yet. rooms appear as people use them."
} else {
if !publicRooms.isEmpty {
discoveryMessage += "public rooms:\n" + publicRooms.sorted().joined(separator: ", ")
}
if !protectedRooms.isEmpty {
if !discoveryMessage.isEmpty { discoveryMessage += "\n\n" }
discoveryMessage += "protected rooms:\n" + protectedRooms.sorted().map { "\($0) 🔒" }.joined(separator: ", ")
}
}
let systemMessage = BitchatMessage(
sender: "system",
content: discoveryMessage,
timestamp: Date(),
isRelay: false
)
messages.append(systemMessage)
case "/transfer":
// Transfer room ownership
let parts = command.split(separator: " ", maxSplits: 1).map(String.init)
@@ -1598,12 +1574,12 @@ extension ChatViewModel: BitchatDelegate {
messages.removeAll()
bitchatLog("cleared main chat", category: "chat")
}
case "/favorite", "/fav":
// Toggle favorite status for current room
case "/save":
// Toggle save status for current room
guard let room = currentRoom else {
let systemMessage = BitchatMessage(
sender: "system",
content: "you must be in a room to mark it as favorite.",
content: "you must be in a room to save it.",
timestamp: Date(),
isRelay: false
)
@@ -1612,7 +1588,7 @@ extension ChatViewModel: BitchatDelegate {
}
let isFavorite = MessageRetentionService.shared.toggleFavoriteRoom(room)
let status = isFavorite ? "added to" : "removed from"
let status = isFavorite ? "saved" : "unsaved"
// If just marked as favorite, load any previously saved messages
if isFavorite {
@@ -1634,7 +1610,7 @@ extension ChatViewModel: BitchatDelegate {
let systemMessage = BitchatMessage(
sender: "system",
content: "room \(room) \(status) favorites. loaded \(savedMessages.count) saved messages.",
content: "room \(room) \(status). loaded \(savedMessages.count) saved messages.",
timestamp: Date(),
isRelay: false
)
@@ -1642,7 +1618,7 @@ extension ChatViewModel: BitchatDelegate {
} else {
let systemMessage = BitchatMessage(
sender: "system",
content: "room \(room) \(status) favorites.",
content: "room \(room) \(status).",
timestamp: Date(),
isRelay: false
)
@@ -1651,7 +1627,7 @@ extension ChatViewModel: BitchatDelegate {
} else {
let systemMessage = BitchatMessage(
sender: "system",
content: "room \(room) \(status) favorites.",
content: "room \(room) \(status).",
timestamp: Date(),
isRelay: false
)
-8
View File
@@ -70,9 +70,6 @@ struct AppInfoView: View {
FeatureRow(icon: "lock.fill", title: "Password Rooms",
description: "Secure rooms with passwords and AES encryption")
FeatureRow(icon: "mic.fill", title: "Voice Notes",
description: "Push-to-talk voice messages with compression")
}
// Privacy
@@ -117,7 +114,6 @@ struct AppInfoView: View {
Text("Battery: Adaptive scanning based on level")
Text("Platform: Universal (iOS, iPadOS, macOS)")
Text("Rooms: Password-protected with key commitments")
Text("Commands: /j /m /w /list /pass /favorite /discover")
Text("Storage: Keychain for passwords, encrypted retention")
}
.font(.system(size: 14, design: .monospaced))
@@ -203,9 +199,6 @@ struct AppInfoView: View {
FeatureRow(icon: "lock.fill", title: "Password Rooms",
description: "Secure rooms with passwords and AES encryption")
FeatureRow(icon: "mic.fill", title: "Voice Notes",
description: "Push-to-talk voice messages with compression")
}
// Privacy
@@ -250,7 +243,6 @@ struct AppInfoView: View {
Text("Battery: Adaptive scanning based on level")
Text("Platform: Universal (iOS, iPadOS, macOS)")
Text("Rooms: Password-protected with key commitments")
Text("Commands: /j /m /w /list /pass /favorite /discover")
Text("Storage: Keychain for passwords, encrypted retention")
}
.font(.system(size: 14, design: .monospaced))
+23 -12
View File
@@ -506,18 +506,24 @@ struct ContentView: View {
// Command suggestions
if showCommandSuggestions && !commandSuggestions.isEmpty {
VStack(alignment: .leading, spacing: 0) {
let commandDescriptions = [
let baseCommands: [String: String] = [
"/j": "join or create a room",
"/list": "show your joined rooms",
"/rooms": "show all discovered rooms",
"/w": "see who's online",
"/m": "send private message",
"/clear": "clear chat messages",
"/clear": "clear chat messages"
]
let roomCommands: [String: String] = [
"/transfer": "transfer room ownership",
"/pass": "change room password",
"/favorite": "toggle room retention",
"/discover": "find active rooms"
"/save": "save room messages locally"
]
let commandDescriptions = viewModel.currentRoom != nil
? baseCommands.merging(roomCommands) { (_, new) in new }
: baseCommands
ForEach(commandSuggestions, id: \.self) { command in
Button(action: {
// Replace current text with selected command
@@ -590,17 +596,22 @@ struct ContentView: View {
// Check for command autocomplete
if newValue.hasPrefix("/") && newValue.count >= 1 {
let commandDescriptions = [
// Build context-aware command list
var commandDescriptions = [
("/j", "join or create a room"),
("/list", "show your joined rooms"),
("/rooms", "show all discovered rooms"),
("/w", "see who's online"),
("/m", "send private message"),
("/clear", "clear chat messages"),
("/transfer", "transfer room ownership"),
("/pass", "change room password"),
("/favorite", "toggle room retention"),
("/discover", "find active rooms")
("/clear", "clear chat messages")
]
// Add room-specific commands if in a room
if viewModel.currentRoom != nil {
commandDescriptions.append(("/transfer", "transfer room ownership"))
commandDescriptions.append(("/pass", "change room password"))
commandDescriptions.append(("/save", "save room messages locally"))
}
let input = newValue.lowercased()
commandSuggestions = commandDescriptions
.filter { $0.0.starts(with: input) }