mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:45:19 +00:00
Merge branch 'main' into update-tor-0.4.8.19
This commit is contained in:
@@ -189,6 +189,10 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
|
|||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applicationWillTerminate(_ application: UIApplication) {
|
||||||
|
chatViewModel?.applicationWillTerminate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
)
|
)
|
||||||
NotificationCenter.default.addObserver(
|
NotificationCenter.default.addObserver(
|
||||||
self,
|
self,
|
||||||
selector: #selector(appWillTerminate),
|
selector: #selector(applicationWillTerminate),
|
||||||
name: NSApplication.willTerminateNotification,
|
name: NSApplication.willTerminateNotification,
|
||||||
object: nil
|
object: nil
|
||||||
)
|
)
|
||||||
@@ -776,7 +776,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
)
|
)
|
||||||
NotificationCenter.default.addObserver(
|
NotificationCenter.default.addObserver(
|
||||||
self,
|
self,
|
||||||
selector: #selector(appWillTerminate),
|
selector: #selector(applicationWillTerminate),
|
||||||
name: UIApplication.willTerminateNotification,
|
name: UIApplication.willTerminateNotification,
|
||||||
object: nil
|
object: nil
|
||||||
)
|
)
|
||||||
@@ -3251,24 +3251,21 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
// No-op; avoid forcing synchronize on resign
|
// No-op; avoid forcing synchronize on resign
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func applicationWillTerminate() {
|
/// Save identity state without stopping services (for backgrounding)
|
||||||
// Send leave message to all peers
|
func saveIdentityState() {
|
||||||
meshService.stopServices()
|
|
||||||
|
|
||||||
// Force save any pending identity changes (verifications, favorites, etc)
|
// Force save any pending identity changes (verifications, favorites, etc)
|
||||||
identityManager.forceSave()
|
identityManager.forceSave()
|
||||||
|
|
||||||
// Verify identity key is still there
|
// Verify identity key is still there
|
||||||
_ = keychain.verifyIdentityKeyExists()
|
_ = keychain.verifyIdentityKeyExists()
|
||||||
|
|
||||||
// No need to force synchronize here
|
|
||||||
|
|
||||||
// Verify identity key after save
|
|
||||||
_ = keychain.verifyIdentityKeyExists()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func appWillTerminate() {
|
@objc func applicationWillTerminate() {
|
||||||
// No need to force synchronize here
|
// Send leave message to all peers
|
||||||
|
meshService.stopServices()
|
||||||
|
|
||||||
|
// Save identity state
|
||||||
|
saveIdentityState()
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@@ -4464,6 +4461,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
|
|
||||||
// Update secure storage with verified status
|
// Update secure storage with verified status
|
||||||
identityManager.setVerified(fingerprint: fingerprint, verified: true)
|
identityManager.setVerified(fingerprint: fingerprint, verified: true)
|
||||||
|
saveIdentityState()
|
||||||
|
|
||||||
// Update local set for UI
|
// Update local set for UI
|
||||||
verifiedFingerprints.insert(fingerprint)
|
verifiedFingerprints.insert(fingerprint)
|
||||||
@@ -4476,7 +4474,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
func unverifyFingerprint(for peerID: PeerID) {
|
func unverifyFingerprint(for peerID: PeerID) {
|
||||||
guard let fingerprint = getFingerprint(for: peerID) else { return }
|
guard let fingerprint = getFingerprint(for: peerID) else { return }
|
||||||
identityManager.setVerified(fingerprint: fingerprint, verified: false)
|
identityManager.setVerified(fingerprint: fingerprint, verified: false)
|
||||||
identityManager.forceSave()
|
saveIdentityState()
|
||||||
verifiedFingerprints.remove(fingerprint)
|
verifiedFingerprints.remove(fingerprint)
|
||||||
updateEncryptionStatus(for: peerID)
|
updateEncryptionStatus(for: peerID)
|
||||||
}
|
}
|
||||||
@@ -4685,7 +4683,7 @@ final class ChatViewModel: ObservableObject, BitchatDelegate {
|
|||||||
let short = fp.prefix(8)
|
let short = fp.prefix(8)
|
||||||
SecureLogger.info("🔐 Marking verified fingerprint: \(short)", category: .security)
|
SecureLogger.info("🔐 Marking verified fingerprint: \(short)", category: .security)
|
||||||
identityManager.setVerified(fingerprint: fp, verified: true)
|
identityManager.setVerified(fingerprint: fp, verified: true)
|
||||||
identityManager.forceSave()
|
saveIdentityState()
|
||||||
verifiedFingerprints.insert(fp)
|
verifiedFingerprints.insert(fp)
|
||||||
let name = unifiedPeerService.getPeer(by: peerID)?.nickname ?? resolveNickname(for: peerID)
|
let name = unifiedPeerService.getPeer(by: peerID)?.nickname ?? resolveNickname(for: peerID)
|
||||||
NotificationService.shared.sendLocalNotification(
|
NotificationService.shared.sendLocalNotification(
|
||||||
|
|||||||
Reference in New Issue
Block a user