mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 22:45:19 +00:00
Non-en languages are each missing ~138 of 336 catalog keys, so a key absent from that language's table renders as the raw dot-key on device (no English fallback). This adds English defaultValues so every miss resolves to English instead of a raw key. - Class (a): 217 String(localized: "dot.key") calls missing defaultValue now carry defaultValue: "<en value>" pulled verbatim from the catalog (format specifiers preserved). - Class (b): 41 SwiftUI LocalizedStringKey literals (Text/Button/alert/ confirmationDialog/TextField) wrapped as Text(String(localized: "key", defaultValue: "en")) so they resolve to English too. Existing comments folded into the resolved String. No catalog or en values changed; Swift source only. Both schemes build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
65 lines
2.3 KiB
Swift
65 lines
2.3 KiB
Swift
//
|
|
// ChatViewModel+Tor.swift
|
|
// bitchat
|
|
//
|
|
// Tor lifecycle handling for ChatViewModel
|
|
//
|
|
|
|
import Foundation
|
|
import Combine
|
|
import Tor
|
|
|
|
extension ChatViewModel {
|
|
|
|
// MARK: - Tor notifications
|
|
|
|
@objc func handleTorWillStart() {
|
|
Task { @MainActor in
|
|
if !self.torStatusAnnounced && TorManager.shared.torEnforced {
|
|
self.torStatusAnnounced = true
|
|
// Post only in geohash channels (queue if not active)
|
|
self.addGeohashOnlySystemMessage(
|
|
String(localized: "system.tor.starting", defaultValue: "starting tor...", comment: "System message when Tor is starting")
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
@objc func handleTorWillRestart() {
|
|
Task { @MainActor in
|
|
self.torRestartPending = true
|
|
// Post only in geohash channels (queue if not active)
|
|
self.addGeohashOnlySystemMessage(
|
|
String(localized: "system.tor.restarting", defaultValue: "tor restarting to recover connectivity...", comment: "System message when Tor is restarting")
|
|
)
|
|
}
|
|
}
|
|
|
|
@objc func handleTorDidBecomeReady() {
|
|
Task { @MainActor in
|
|
// Only announce "restarted" if we actually restarted this session
|
|
if self.torRestartPending {
|
|
// Post only in geohash channels (queue if not active)
|
|
self.addGeohashOnlySystemMessage(
|
|
String(localized: "system.tor.restarted", defaultValue: "tor restarted. network routing restored.", comment: "System message when Tor has restarted")
|
|
)
|
|
self.torRestartPending = false
|
|
} else if TorManager.shared.torEnforced && !self.torInitialReadyAnnounced {
|
|
// Initial start completed
|
|
self.addGeohashOnlySystemMessage(
|
|
String(localized: "system.tor.started", defaultValue: "tor started. routing all chats via tor for IP privacy.", comment: "System message when Tor has started")
|
|
)
|
|
self.torInitialReadyAnnounced = true
|
|
}
|
|
}
|
|
}
|
|
|
|
@objc func handleTorPreferenceChanged(_ notification: Notification) {
|
|
Task { @MainActor in
|
|
self.torStatusAnnounced = false
|
|
self.torInitialReadyAnnounced = false
|
|
self.torRestartPending = false
|
|
}
|
|
}
|
|
}
|