Expose leave chat to iOS bridge

This commit is contained in:
Mikhail Kilin
2026-05-21 00:45:39 +03:00
parent 928a5aeda2
commit f7abd1dba0
7 changed files with 57 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ public protocol SessionBridge: Sendable {
func loadHistory(chatId: Int64) async throws -> [Message]
func searchMessages(chatId: Int64, query: String) async throws -> [Message]
func openProfile(chatId: Int64) async throws -> Profile
func leaveChat(chatId: Int64) async throws
func sendMessage(chatId: Int64, text: String, replyToMessageId: Int64?) async throws -> Message
func editMessage(chatId: Int64, messageId: Int64, text: String) async throws -> Message
func deleteMessages(chatId: Int64, messageIds: [Int64]) async throws
@@ -132,6 +133,12 @@ public actor FakeSessionBridge: SessionBridge {
return profile
}
public func leaveChat(chatId: Int64) async throws {
chats.removeAll { $0.id == chatId }
messages.removeValue(forKey: chatId)
events.append(.chatListChanged(chats))
}
public func sendMessage(chatId: Int64, text: String, replyToMessageId: Int64?) async throws -> Message {
let message = Message(
id: nextMessageId,