diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 5781d3c4db..a89a061af9 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -361,7 +361,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[2107670217] = { return Api.InputPeer.parse_inputPeerSelf($0) } dict[-571955892] = { return Api.InputPeer.parse_inputPeerUser($0) } dict[-1468331492] = { return Api.InputPeer.parse_inputPeerUserFromMessage($0) } - dict[-551616469] = { return Api.InputPeerNotifySettings.parse_inputPeerNotifySettings($0) } + dict[-505078139] = { return Api.InputPeerNotifySettings.parse_inputPeerNotifySettings($0) } dict[506920429] = { return Api.InputPhoneCall.parse_inputPhoneCall($0) } dict[1001634122] = { return Api.InputPhoto.parse_inputPhoto($0) } dict[483901197] = { return Api.InputPhoto.parse_inputPhotoEmpty($0) } @@ -528,7 +528,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) } dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) } dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) } - dict[-946147823] = { return Api.MessageMedia.parse_messageMediaStory($0) } + dict[-877523576] = { return Api.MessageMedia.parse_messageMediaStory($0) } dict[-1618676578] = { return Api.MessageMedia.parse_messageMediaUnsupported($0) } dict[784356159] = { return Api.MessageMedia.parse_messageMediaVenue($0) } dict[-1557277184] = { return Api.MessageMedia.parse_messageMediaWebPage($0) } @@ -619,7 +619,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-386039788] = { return Api.PeerBlocked.parse_peerBlocked($0) } dict[-901375139] = { return Api.PeerLocated.parse_peerLocated($0) } dict[-118740917] = { return Api.PeerLocated.parse_peerSelfLocated($0) } - dict[-1472527322] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) } + dict[1826385490] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) } dict[-1525149427] = { return Api.PeerSettings.parse_peerSettings($0) } dict[-1770029977] = { return Api.PhoneCall.parse_phoneCall($0) } dict[912311057] = { return Api.PhoneCall.parse_phoneCallAccepted($0) } diff --git a/submodules/TelegramApi/Sources/Api13.swift b/submodules/TelegramApi/Sources/Api13.swift index 897b4fdecf..0e0f0fd124 100644 --- a/submodules/TelegramApi/Sources/Api13.swift +++ b/submodules/TelegramApi/Sources/Api13.swift @@ -744,7 +744,7 @@ public extension Api { case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?) case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?) case messageMediaPoll(poll: Api.Poll, results: Api.PollResults) - case messageMediaStory(userId: Int64, id: Int32) + case messageMediaStory(flags: Int32, userId: Int64, id: Int32, story: Api.StoryItem?) case messageMediaUnsupported case messageMediaVenue(geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String) case messageMediaWebPage(webpage: Api.WebPage) @@ -834,12 +834,14 @@ public extension Api { poll.serialize(buffer, true) results.serialize(buffer, true) break - case .messageMediaStory(let userId, let id): + case .messageMediaStory(let flags, let userId, let id, let story): if boxed { - buffer.appendInt32(-946147823) + buffer.appendInt32(-877523576) } + serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {story!.serialize(buffer, true)} break case .messageMediaUnsupported: if boxed { @@ -889,8 +891,8 @@ public extension Api { return ("messageMediaPhoto", [("flags", flags as Any), ("photo", photo as Any), ("ttlSeconds", ttlSeconds as Any)]) case .messageMediaPoll(let poll, let results): return ("messageMediaPoll", [("poll", poll as Any), ("results", results as Any)]) - case .messageMediaStory(let userId, let id): - return ("messageMediaStory", [("userId", userId as Any), ("id", id as Any)]) + case .messageMediaStory(let flags, let userId, let id, let story): + return ("messageMediaStory", [("flags", flags as Any), ("userId", userId as Any), ("id", id as Any), ("story", story as Any)]) case .messageMediaUnsupported: return ("messageMediaUnsupported", []) case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType): @@ -1092,14 +1094,22 @@ public extension Api { } } public static func parse_messageMediaStory(_ reader: BufferReader) -> MessageMedia? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int32? + _3 = reader.readInt32() + var _4: Api.StoryItem? + if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { + _4 = Api.parse(reader, signature: signature) as? Api.StoryItem + } } let _c1 = _1 != nil let _c2 = _2 != nil - if _c1 && _c2 { - return Api.MessageMedia.messageMediaStory(userId: _1!, id: _2!) + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.MessageMedia.messageMediaStory(flags: _1!, userId: _2!, id: _3!, story: _4) } else { return nil diff --git a/submodules/TelegramApi/Sources/Api16.swift b/submodules/TelegramApi/Sources/Api16.swift index 8981915c7f..5e8d704f16 100644 --- a/submodules/TelegramApi/Sources/Api16.swift +++ b/submodules/TelegramApi/Sources/Api16.swift @@ -754,13 +754,13 @@ public extension Api { } public extension Api { enum PeerNotifySettings: TypeConstructorDescription { - case peerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, iosSound: Api.NotificationSound?, androidSound: Api.NotificationSound?, otherSound: Api.NotificationSound?) + case peerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, iosSound: Api.NotificationSound?, androidSound: Api.NotificationSound?, otherSound: Api.NotificationSound?, storiesMuted: Api.Bool?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .peerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let iosSound, let androidSound, let otherSound): + case .peerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let iosSound, let androidSound, let otherSound, let storiesMuted): if boxed { - buffer.appendInt32(-1472527322) + buffer.appendInt32(1826385490) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {showPreviews!.serialize(buffer, true)} @@ -769,14 +769,15 @@ public extension Api { if Int(flags) & Int(1 << 3) != 0 {iosSound!.serialize(buffer, true)} if Int(flags) & Int(1 << 4) != 0 {androidSound!.serialize(buffer, true)} if Int(flags) & Int(1 << 5) != 0 {otherSound!.serialize(buffer, true)} + if Int(flags) & Int(1 << 6) != 0 {storiesMuted!.serialize(buffer, true)} break } } public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .peerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let iosSound, let androidSound, let otherSound): - return ("peerNotifySettings", [("flags", flags as Any), ("showPreviews", showPreviews as Any), ("silent", silent as Any), ("muteUntil", muteUntil as Any), ("iosSound", iosSound as Any), ("androidSound", androidSound as Any), ("otherSound", otherSound as Any)]) + case .peerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let iosSound, let androidSound, let otherSound, let storiesMuted): + return ("peerNotifySettings", [("flags", flags as Any), ("showPreviews", showPreviews as Any), ("silent", silent as Any), ("muteUntil", muteUntil as Any), ("iosSound", iosSound as Any), ("androidSound", androidSound as Any), ("otherSound", otherSound as Any), ("storiesMuted", storiesMuted as Any)]) } } @@ -805,6 +806,10 @@ public extension Api { if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() { _7 = Api.parse(reader, signature: signature) as? Api.NotificationSound } } + var _8: Api.Bool? + if Int(_1!) & Int(1 << 6) != 0 {if let signature = reader.readInt32() { + _8 = Api.parse(reader, signature: signature) as? Api.Bool + } } let _c1 = _1 != nil let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil @@ -812,8 +817,9 @@ public extension Api { let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil let _c6 = (Int(_1!) & Int(1 << 4) == 0) || _6 != nil let _c7 = (Int(_1!) & Int(1 << 5) == 0) || _7 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { - return Api.PeerNotifySettings.peerNotifySettings(flags: _1!, showPreviews: _2, silent: _3, muteUntil: _4, iosSound: _5, androidSound: _6, otherSound: _7) + let _c8 = (Int(_1!) & Int(1 << 6) == 0) || _8 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { + return Api.PeerNotifySettings.peerNotifySettings(flags: _1!, showPreviews: _2, silent: _3, muteUntil: _4, iosSound: _5, androidSound: _6, otherSound: _7, storiesMuted: _8) } else { return nil diff --git a/submodules/TelegramApi/Sources/Api9.swift b/submodules/TelegramApi/Sources/Api9.swift index da64ca95fc..fbdbbf9cbe 100644 --- a/submodules/TelegramApi/Sources/Api9.swift +++ b/submodules/TelegramApi/Sources/Api9.swift @@ -278,27 +278,28 @@ public extension Api { } public extension Api { enum InputPeerNotifySettings: TypeConstructorDescription { - case inputPeerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, sound: Api.NotificationSound?) + case inputPeerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, sound: Api.NotificationSound?, storiesMuted: Api.Bool?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .inputPeerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let sound): + case .inputPeerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let sound, let storiesMuted): if boxed { - buffer.appendInt32(-551616469) + buffer.appendInt32(-505078139) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {showPreviews!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {silent!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {serializeInt32(muteUntil!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {sound!.serialize(buffer, true)} + if Int(flags) & Int(1 << 6) != 0 {storiesMuted!.serialize(buffer, true)} break } } public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .inputPeerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let sound): - return ("inputPeerNotifySettings", [("flags", flags as Any), ("showPreviews", showPreviews as Any), ("silent", silent as Any), ("muteUntil", muteUntil as Any), ("sound", sound as Any)]) + case .inputPeerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let sound, let storiesMuted): + return ("inputPeerNotifySettings", [("flags", flags as Any), ("showPreviews", showPreviews as Any), ("silent", silent as Any), ("muteUntil", muteUntil as Any), ("sound", sound as Any), ("storiesMuted", storiesMuted as Any)]) } } @@ -319,13 +320,18 @@ public extension Api { if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { _5 = Api.parse(reader, signature: signature) as? Api.NotificationSound } } + var _6: Api.Bool? + if Int(_1!) & Int(1 << 6) != 0 {if let signature = reader.readInt32() { + _6 = Api.parse(reader, signature: signature) as? Api.Bool + } } let _c1 = _1 != nil let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: _1!, showPreviews: _2, silent: _3, muteUntil: _4, sound: _5) + let _c6 = (Int(_1!) & Int(1 << 6) == 0) || _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: _1!, showPreviews: _2, silent: _3, muteUntil: _4, sound: _5, storiesMuted: _6) } else { return nil diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index aac9489a44..f1e148fb82 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -380,7 +380,7 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI } case let .messageMediaDice(value, emoticon): return (TelegramMediaDice(emoji: emoticon, value: value), nil, nil, nil) - case let .messageMediaStory(userId, id): + case let .messageMediaStory(_, userId, id, _): return (TelegramMediaStory(storyId: StoryId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), id: id)), nil, nil, nil) } } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramPeerNotificationSettings.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramPeerNotificationSettings.swift index 920266a577..09ba02cd2e 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramPeerNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramPeerNotificationSettings.swift @@ -6,7 +6,7 @@ import TelegramApi extension TelegramPeerNotificationSettings { convenience init(apiSettings: Api.PeerNotifySettings) { switch apiSettings { - case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound): + case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted): let sound: Api.NotificationSound? #if os(iOS) sound = iosSound @@ -34,7 +34,13 @@ extension TelegramPeerNotificationSettings { } else { displayPreviews = .default } - self.init(muteState: muteState, messageSound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault), displayPreviews: displayPreviews) + + var storiesMutedValue: Bool? + if let storiesMuted = storiesMuted { + storiesMutedValue = storiesMuted == .boolTrue + } + + self.init(muteState: muteState, messageSound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault), displayPreviews: displayPreviews, storiesMuted: storiesMutedValue) } } } diff --git a/submodules/TelegramCore/Sources/Settings/GlobalNotificationSettings.swift b/submodules/TelegramCore/Sources/Settings/GlobalNotificationSettings.swift index 20c835757d..a59a986843 100644 --- a/submodules/TelegramCore/Sources/Settings/GlobalNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/Settings/GlobalNotificationSettings.swift @@ -6,7 +6,7 @@ import TelegramApi extension MessageNotificationSettings { init(apiSettings: Api.PeerNotifySettings) { switch apiSettings { - case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound): + case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted): let sound: Api.NotificationSound? #if os(iOS) sound = iosSound @@ -19,7 +19,11 @@ extension MessageNotificationSettings { } else { displayPreviews = true } - self = MessageNotificationSettings(enabled: muteUntil == 0, displayPreviews: displayPreviews, sound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault)) + var storiesMutedValue: Bool? + if let storiesMuted = storiesMuted { + storiesMutedValue = storiesMuted == .boolTrue + } + self = MessageNotificationSettings(enabled: muteUntil == 0, displayPreviews: displayPreviews, sound: PeerMessageSound(apiSound: sound ?? .notificationSoundDefault), storiesMuted: storiesMutedValue) } } } diff --git a/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift b/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift index 567a3df1c0..7942519e36 100644 --- a/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift @@ -116,7 +116,7 @@ private func fetchedNotificationSettings(network: Network) -> Signal map { chats, users, channels, contactsJoinedMuted in let chatsSettings: MessageNotificationSettings switch chats { - case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound): + case let .peerNotifySettings(_, showPreviews, _, muteUntil, iosSound, _, desktopSound, storiesMuted): let sound: Api.NotificationSound? #if os(iOS) sound = iosSound @@ -136,12 +136,18 @@ private func fetchedNotificationSettings(network: Network) -> Signal Signal Signal Signal { diff --git a/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift b/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift index 2f817a367c..8cf808ffb3 100644 --- a/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift @@ -130,7 +130,13 @@ func pushPeerNotificationSettings(postbox: Postbox, network: Network, peerId: Pe if sound != nil { flags |= (1 << 3) } - let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound) + var storiesMuted: Api.Bool? + if let storiesMutedValue = settings.storiesMuted { + flags |= (1 << 6) + storiesMuted = storiesMutedValue ? .boolTrue : .boolFalse + } + + let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted) return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyForumTopic(peer: inputPeer, topMsgId: Int32(clamping: threadId)), settings: inputSettings)) |> `catch` { _ -> Signal in return .single(.boolFalse) @@ -173,7 +179,12 @@ func pushPeerNotificationSettings(postbox: Postbox, network: Network, peerId: Pe if sound != nil { flags |= (1 << 3) } - let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound) + var storiesMuted: Api.Bool? + if let storiesMutedValue = settings.storiesMuted { + flags |= (1 << 6) + storiesMuted = storiesMutedValue ? .boolTrue : .boolFalse + } + let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted) return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyPeer(peer: inputPeer), settings: inputSettings)) |> `catch` { _ -> Signal in return .single(.boolFalse) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift index db282a09d3..a3d03cd13f 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift @@ -4,15 +4,17 @@ public struct MessageNotificationSettings: Codable, Equatable { public var enabled: Bool public var displayPreviews: Bool public var sound: PeerMessageSound + public var storiesMuted: Bool? public static var defaultSettings: MessageNotificationSettings { - return MessageNotificationSettings(enabled: true, displayPreviews: true, sound: defaultCloudPeerNotificationSound) + return MessageNotificationSettings(enabled: true, displayPreviews: true, sound: defaultCloudPeerNotificationSound, storiesMuted: nil) } - public init(enabled: Bool, displayPreviews: Bool, sound: PeerMessageSound) { + public init(enabled: Bool, displayPreviews: Bool, sound: PeerMessageSound, storiesMuted: Bool?) { self.enabled = enabled self.displayPreviews = displayPreviews self.sound = sound + self.storiesMuted = storiesMuted } public init(from decoder: Decoder) throws { @@ -22,6 +24,8 @@ public struct MessageNotificationSettings: Codable, Equatable { self.displayPreviews = ((try? container.decode(Int32.self, forKey: "p")) ?? 0) != 0 self.sound = try PeerMessageSound.decodeInline(container) + + self.storiesMuted = try? container.decodeIfPresent(Bool.self, forKey: "st") } public func encode(to encoder: Encoder) throws { @@ -30,6 +34,7 @@ public struct MessageNotificationSettings: Codable, Equatable { try container.encode((self.enabled ? 1 : 0) as Int32, forKey: "e") try container.encode((self.displayPreviews ? 1 : 0) as Int32, forKey: "p") try self.sound.encodeInline(&container) + try container.encodeIfPresent(self.storiesMuted, forKey: "st") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift index 982c7a05b9..9e5a068655 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift @@ -392,9 +392,10 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, C public let muteState: PeerMuteState public let messageSound: PeerMessageSound public let displayPreviews: PeerNotificationDisplayPreviews + public let storiesMuted: Bool? public static var defaultSettings: TelegramPeerNotificationSettings { - return TelegramPeerNotificationSettings(muteState: .unmuted, messageSound: .default, displayPreviews: .default) + return TelegramPeerNotificationSettings(muteState: .unmuted, messageSound: .default, displayPreviews: .default, storiesMuted: nil) } public func isRemovedFromTotalUnreadCount(`default`: Bool) -> Bool { @@ -416,16 +417,18 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, C } } - public init(muteState: PeerMuteState, messageSound: PeerMessageSound, displayPreviews: PeerNotificationDisplayPreviews) { + public init(muteState: PeerMuteState, messageSound: PeerMessageSound, displayPreviews: PeerNotificationDisplayPreviews, storiesMuted: Bool?) { self.muteState = muteState self.messageSound = messageSound self.displayPreviews = displayPreviews + self.storiesMuted = storiesMuted } public init(decoder: PostboxDecoder) { self.muteState = PeerMuteState.decodeInline(decoder) self.messageSound = PeerMessageSound.decodeInline(decoder) self.displayPreviews = PeerNotificationDisplayPreviews.decodeInline(decoder) + self.storiesMuted = decoder.decodeOptionalBoolForKey("stm") } public init(from decoder: Decoder) throws { @@ -434,6 +437,7 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, C self.muteState = try container.decode(PeerMuteState.self, forKey: "muteState") self.messageSound = try container.decode(PeerMessageSound.self, forKey: "messageSound") self.displayPreviews = try container.decode(PeerNotificationDisplayPreviews.self, forKey: "displayPreviews") + self.storiesMuted = try? container.decodeIfPresent(Bool.self, forKey: "stm") } public func encode(to encoder: Encoder) throws { @@ -442,12 +446,18 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, C try container.encode(self.muteState, forKey: "muteState") try container.encode(self.messageSound, forKey: "messageSound") try container.encode(self.displayPreviews, forKey: "displayPreviews") + try container.encodeIfPresent(self.storiesMuted, forKey: "stm") } public func encode(_ encoder: PostboxEncoder) { self.muteState.encodeInline(encoder) self.messageSound.encodeInline(encoder) self.displayPreviews.encodeInline(encoder) + if let storiesMuted = self.storiesMuted { + encoder.encodeBool(storiesMuted, forKey: "stm") + } else { + encoder.encodeNil(forKey: "stm") + } } public func isEqual(to: PeerNotificationSettings) -> Bool { @@ -459,18 +469,22 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, C } public func withUpdatedMuteState(_ muteState: PeerMuteState) -> TelegramPeerNotificationSettings { - return TelegramPeerNotificationSettings(muteState: muteState, messageSound: self.messageSound, displayPreviews: self.displayPreviews) + return TelegramPeerNotificationSettings(muteState: muteState, messageSound: self.messageSound, displayPreviews: self.displayPreviews, storiesMuted: self.storiesMuted) } public func withUpdatedMessageSound(_ messageSound: PeerMessageSound) -> TelegramPeerNotificationSettings { - return TelegramPeerNotificationSettings(muteState: self.muteState, messageSound: messageSound, displayPreviews: self.displayPreviews) + return TelegramPeerNotificationSettings(muteState: self.muteState, messageSound: messageSound, displayPreviews: self.displayPreviews, storiesMuted: self.storiesMuted) } public func withUpdatedDisplayPreviews(_ displayPreviews: PeerNotificationDisplayPreviews) -> TelegramPeerNotificationSettings { - return TelegramPeerNotificationSettings(muteState: self.muteState, messageSound: self.messageSound, displayPreviews: displayPreviews) + return TelegramPeerNotificationSettings(muteState: self.muteState, messageSound: self.messageSound, displayPreviews: displayPreviews, storiesMuted: self.storiesMuted) + } + + public func withUpdatedStoriesMuted(_ storiesMuted: Bool?) -> TelegramPeerNotificationSettings { + return TelegramPeerNotificationSettings(muteState: self.muteState, messageSound: self.messageSound, displayPreviews: self.displayPreviews, storiesMuted: storiesMuted) } public static func ==(lhs: TelegramPeerNotificationSettings, rhs: TelegramPeerNotificationSettings) -> Bool { - return lhs.muteState == rhs.muteState && lhs.messageSound == rhs.messageSound && lhs.displayPreviews == rhs.displayPreviews + return lhs.muteState == rhs.muteState && lhs.messageSound == rhs.messageSound && lhs.displayPreviews == rhs.displayPreviews && lhs.storiesMuted == rhs.storiesMuted } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift index f1bf3d4eef..c82fbd6cbd 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift @@ -88,15 +88,18 @@ public enum EnginePeer: Equatable { public var muteState: MuteState public var messageSound: MessageSound public var displayPreviews: DisplayPreviews + public var storiesMuted: Bool? public init( muteState: MuteState, messageSound: MessageSound, - displayPreviews: DisplayPreviews + displayPreviews: DisplayPreviews, + storiesMuted: Bool? ) { self.muteState = muteState self.messageSound = messageSound self.displayPreviews = displayPreviews + self.storiesMuted = storiesMuted } } @@ -216,11 +219,13 @@ public struct EngineGlobalNotificationSettings: Equatable { public var enabled: Bool public var displayPreviews: Bool public var sound: EnginePeer.NotificationSettings.MessageSound + public var storiesMuted: Bool - public init(enabled: Bool, displayPreviews: Bool, sound: EnginePeer.NotificationSettings.MessageSound) { + public init(enabled: Bool, displayPreviews: Bool, sound: EnginePeer.NotificationSettings.MessageSound, storiesMuted: Bool) { self.enabled = enabled self.displayPreviews = displayPreviews self.sound = sound + self.storiesMuted = storiesMuted } } @@ -327,7 +332,8 @@ public extension EnginePeer.NotificationSettings { self.init( muteState: MuteState(notificationSettings.muteState), messageSound: MessageSound(notificationSettings.messageSound), - displayPreviews: DisplayPreviews(notificationSettings.displayPreviews) + displayPreviews: DisplayPreviews(notificationSettings.displayPreviews), + storiesMuted: notificationSettings.storiesMuted ) } @@ -335,7 +341,8 @@ public extension EnginePeer.NotificationSettings { return TelegramPeerNotificationSettings( muteState: self.muteState._asMuteState(), messageSound: self.messageSound._asMessageSound(), - displayPreviews: self.displayPreviews._asDisplayPreviews() + displayPreviews: self.displayPreviews._asDisplayPreviews(), + storiesMuted: self.storiesMuted ) } } @@ -594,7 +601,8 @@ public extension EngineGlobalNotificationSettings.CategorySettings { self.init( enabled: categorySettings.enabled, displayPreviews: categorySettings.displayPreviews, - sound: EnginePeer.NotificationSettings.MessageSound(categorySettings.sound) + sound: EnginePeer.NotificationSettings.MessageSound(categorySettings.sound), + storiesMuted: categorySettings.storiesMuted ?? false ) } @@ -602,7 +610,8 @@ public extension EngineGlobalNotificationSettings.CategorySettings { return MessageNotificationSettings( enabled: self.enabled, displayPreviews: self.displayPreviews, - sound: self.sound._asMessageSound() + sound: self.sound._asMessageSound(), + storiesMuted: self.storiesMuted ) } } diff --git a/submodules/TelegramUI/Components/MediaEditor/MetalResources/EditorVideo.metal b/submodules/TelegramUI/Components/MediaEditor/MetalResources/EditorVideo.metal index 24d0047e79..09be09a74e 100644 --- a/submodules/TelegramUI/Components/MediaEditor/MetalResources/EditorVideo.metal +++ b/submodules/TelegramUI/Components/MediaEditor/MetalResources/EditorVideo.metal @@ -22,10 +22,11 @@ float sRGB_nonLinearNormToLinear(float normV) static inline float4 sRGB_gamma_decode(const float4 rgba) { - rgba.r = sRGB_nonLinearNormToLinear(rgba.r); - rgba.g = sRGB_nonLinearNormToLinear(rgba.g); - rgba.b = sRGB_nonLinearNormToLinear(rgba.b); - return rgba; + float4 tmp = rgba; + tmp.r = sRGB_nonLinearNormToLinear(rgba.r); + tmp.g = sRGB_nonLinearNormToLinear(rgba.g); + tmp.b = sRGB_nonLinearNormToLinear(rgba.b); + return tmp; } static inline float4 BT709_decode(const float Y, const float Cb, const float Cr) { diff --git a/submodules/TelegramUI/Components/NotificationPeerExceptionController/Sources/NotificationPeerExceptionController.swift b/submodules/TelegramUI/Components/NotificationPeerExceptionController/Sources/NotificationPeerExceptionController.swift index de14533077..f1bacf35a0 100644 --- a/submodules/TelegramUI/Components/NotificationPeerExceptionController/Sources/NotificationPeerExceptionController.swift +++ b/submodules/TelegramUI/Components/NotificationPeerExceptionController/Sources/NotificationPeerExceptionController.swift @@ -113,7 +113,7 @@ public enum NotificationExceptionMode : Equatable { case .default: break default: - values[peerId] = NotificationExceptionWrapper(settings: TelegramPeerNotificationSettings(muteState: .default, messageSound: sound, displayPreviews: .default), peer: peer, date: Date().timeIntervalSince1970) + values[peerId] = NotificationExceptionWrapper(settings: TelegramPeerNotificationSettings(muteState: .default, messageSound: sound, displayPreviews: .default, storiesMuted: nil), peer: peer, date: Date().timeIntervalSince1970) } } return values @@ -149,7 +149,7 @@ public enum NotificationExceptionMode : Equatable { case .default: break default: - values[peerId] = NotificationExceptionWrapper(settings: TelegramPeerNotificationSettings(muteState: muteState, messageSound: .default, displayPreviews: .default), peer: peer, date: Date().timeIntervalSince1970) + values[peerId] = NotificationExceptionWrapper(settings: TelegramPeerNotificationSettings(muteState: muteState, messageSound: .default, displayPreviews: .default, storiesMuted: nil), peer: peer, date: Date().timeIntervalSince1970) } } return values @@ -201,7 +201,7 @@ public enum NotificationExceptionMode : Equatable { case .default: break default: - values[peerId] = NotificationExceptionWrapper(settings: TelegramPeerNotificationSettings(muteState: .unmuted, messageSound: .default, displayPreviews: displayPreviews), peer: peer, date: Date().timeIntervalSince1970) + values[peerId] = NotificationExceptionWrapper(settings: TelegramPeerNotificationSettings(muteState: .unmuted, messageSound: .default, displayPreviews: displayPreviews, storiesMuted: nil), peer: peer, date: Date().timeIntervalSince1970) } } return values