mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
26 lines
876 B
Swift
26 lines
876 B
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramApi
|
|
|
|
|
|
extension MessageNotificationSettings {
|
|
init(apiSettings: Api.PeerNotifySettings) {
|
|
switch apiSettings {
|
|
case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound):
|
|
let sound: Api.NotificationSound?
|
|
#if os(iOS)
|
|
sound = iosSound
|
|
#elseif os(macOS)
|
|
sound = desktopSound
|
|
#endif
|
|
let displayPreviews: Bool
|
|
if let showPreviews = showPreviews, case .boolFalse = showPreviews {
|
|
displayPreviews = false
|
|
} else {
|
|
displayPreviews = true
|
|
}
|
|
self = MessageNotificationSettings(enabled: muteUntil == 0, displayPreviews: displayPreviews, sound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault))
|
|
}
|
|
}
|
|
}
|