mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Stories
This commit is contained in:
@@ -6,24 +6,48 @@ import TelegramApi
|
||||
extension MessageNotificationSettings {
|
||||
init(apiSettings: Api.PeerNotifySettings) {
|
||||
switch apiSettings {
|
||||
case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, _, _, _, _):
|
||||
case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted, storiesHideSender, storiesIosSound, _, storiesDesktopSound):
|
||||
let sound: Api.NotificationSound?
|
||||
let storiesSound: Api.NotificationSound?
|
||||
#if os(iOS)
|
||||
sound = iosSound
|
||||
storiesSound = storiesIosSound
|
||||
#elseif os(macOS)
|
||||
sound = desktopSound
|
||||
storiesSound = storiesDesktopSound
|
||||
#endif
|
||||
|
||||
let displayPreviews: Bool
|
||||
if let showPreviews = showPreviews, case .boolFalse = showPreviews {
|
||||
displayPreviews = false
|
||||
} else {
|
||||
displayPreviews = true
|
||||
}
|
||||
var storiesMutedValue: Bool?
|
||||
|
||||
let storiesMutedValue: PeerStoryNotificationSettings.Mute
|
||||
if let storiesMuted = storiesMuted {
|
||||
storiesMutedValue = storiesMuted == .boolTrue
|
||||
storiesMutedValue = storiesMuted == .boolTrue ? .muted : .unmuted
|
||||
} else {
|
||||
storiesMutedValue = .default
|
||||
}
|
||||
self = MessageNotificationSettings(enabled: muteUntil == 0, displayPreviews: displayPreviews, sound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault), storiesMuted: storiesMutedValue)
|
||||
|
||||
var storiesHideSenderValue: PeerStoryNotificationSettings.HideSender
|
||||
if let storiesHideSender = storiesHideSender {
|
||||
storiesHideSenderValue = storiesHideSender == .boolTrue ? .hide : .show
|
||||
} else {
|
||||
storiesHideSenderValue = .default
|
||||
}
|
||||
|
||||
self = MessageNotificationSettings(
|
||||
enabled: muteUntil == 0,
|
||||
displayPreviews: displayPreviews,
|
||||
sound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault),
|
||||
storySettings: PeerStoryNotificationSettings(
|
||||
mute: storiesMutedValue,
|
||||
hideSender: storiesHideSenderValue,
|
||||
sound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user