mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 00:05:18 +00:00
Cut private message path over to ConversationStore
All private-message mutations now flow through store intents: coordinators, PrivateChatManager (its @Published dicts deleted - now read-only views over the store), outbound sends, delivery status, and chat migration. The O(1) store dedup replaces the full-scan duplicate check; insertion order is maintained by the store so sanitizeChat's re-sort is a documented no-op. Both bootstrapper Combine bridges and the Task.yield store synchronization are deleted. ChatViewModel.privateChats/unreadPrivateMessages become get-only derived views (measured: naive rebuild equals a change-invalidated cache within noise, so the simpler form stays). Feature models still read the legacy store, fed by a coalescing LegacyConversationStoreBridge (one mirror per burst, marked for step-5 deletion). pipeline.privateIngest: 9.6k -> 14.7k msg/s (+53%). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -111,7 +111,6 @@ private final class MockChatPublicConversationContext: ChatPublicConversationCon
|
||||
private(set) var conversationActiveChannels: [ChannelID] = []
|
||||
private(set) var replacedChannelMessages: [(channel: ChannelID, messageIDs: [String])] = []
|
||||
private(set) var replacedConversationMessages: [(conversation: ConversationID, messageIDs: [String])] = []
|
||||
private(set) var privateStoreSyncCount = 0
|
||||
private(set) var selectionStoreSyncCount = 0
|
||||
|
||||
func setConversationActiveChannel(_ channel: ChannelID) {
|
||||
@@ -126,10 +125,6 @@ private final class MockChatPublicConversationContext: ChatPublicConversationCon
|
||||
replacedConversationMessages.append((conversationID, messages.map(\.id)))
|
||||
}
|
||||
|
||||
func synchronizePrivateConversationStore() {
|
||||
privateStoreSyncCount += 1
|
||||
}
|
||||
|
||||
func synchronizeConversationSelectionStore() {
|
||||
selectionStoreSyncCount += 1
|
||||
}
|
||||
@@ -137,8 +132,31 @@ private final class MockChatPublicConversationContext: ChatPublicConversationCon
|
||||
// Private chats
|
||||
var privateChats: [PeerID: [BitchatMessage]] = [:]
|
||||
var unreadPrivateMessages: Set<PeerID> = []
|
||||
private(set) var removedPrivateChats: [PeerID] = []
|
||||
private(set) var cleanedUpFileMessageIDs: [String] = []
|
||||
|
||||
func removePrivateChat(_ peerID: PeerID) {
|
||||
removedPrivateChats.append(peerID)
|
||||
privateChats.removeValue(forKey: peerID)
|
||||
unreadPrivateMessages.remove(peerID)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func removePrivateMessage(withID messageID: String) -> BitchatMessage? {
|
||||
var removed: BitchatMessage?
|
||||
for (peerID, chat) in privateChats {
|
||||
guard let message = chat.first(where: { $0.id == messageID }) else { continue }
|
||||
removed = removed ?? message
|
||||
let remaining = chat.filter { $0.id != messageID }
|
||||
if remaining.isEmpty {
|
||||
privateChats.removeValue(forKey: peerID)
|
||||
} else {
|
||||
privateChats[peerID] = remaining
|
||||
}
|
||||
}
|
||||
return removed
|
||||
}
|
||||
|
||||
func cleanupLocalFile(forMessage message: BitchatMessage) {
|
||||
cleanedUpFileMessageIDs.append(message.id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user