Добавлен encryptWithPasswordDesktopCompat (SHA1+zlibDeflate) для кросс-платформенных данных (aesChachaKey, аватар) 3 вызова в SessionManager переведены на desktop-compatible путь Добавлен Notification.Name.profileDidUpdate для мгновенного обновления имени в Settings Удалены debug-логи из CryptoManager и SessionManager
65 lines
1.5 KiB
Swift
65 lines
1.5 KiB
Swift
import Foundation
|
|
|
|
/// Navigation payload for opening a direct chat.
|
|
struct ChatRoute: Hashable {
|
|
let publicKey: String
|
|
let title: String
|
|
let username: String
|
|
let verified: Int
|
|
|
|
init(publicKey: String, title: String, username: String, verified: Int) {
|
|
self.publicKey = publicKey
|
|
self.title = title
|
|
self.username = username
|
|
self.verified = verified
|
|
}
|
|
|
|
init(dialog: Dialog) {
|
|
self.init(
|
|
publicKey: dialog.opponentKey,
|
|
title: dialog.opponentTitle,
|
|
username: dialog.opponentUsername,
|
|
verified: dialog.verified
|
|
)
|
|
}
|
|
|
|
init(user: SearchUser) {
|
|
self.init(
|
|
publicKey: user.publicKey,
|
|
title: user.title,
|
|
username: user.username,
|
|
verified: user.verified
|
|
)
|
|
}
|
|
|
|
init(recent: RecentSearch) {
|
|
self.init(
|
|
publicKey: recent.publicKey,
|
|
title: recent.title,
|
|
username: recent.username,
|
|
verified: recent.verified
|
|
)
|
|
}
|
|
|
|
var isSavedMessages: Bool {
|
|
publicKey == SessionManager.shared.currentPublicKey
|
|
}
|
|
|
|
var isSystemAccount: Bool {
|
|
SystemAccounts.isSystemAccount(publicKey)
|
|
}
|
|
|
|
var displayTitle: String {
|
|
if isSavedMessages {
|
|
return "Saved Messages"
|
|
}
|
|
if !title.isEmpty {
|
|
return title
|
|
}
|
|
if !username.isEmpty {
|
|
return "@\(username)"
|
|
}
|
|
return String(publicKey.prefix(12))
|
|
}
|
|
}
|