mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +00:00
Fix notification exceptions
This commit is contained in:
parent
4d3639f950
commit
377148194a
@ -747,7 +747,7 @@ func chatForumTopicMenuItems(context: AccountContext, peerId: PeerId, threadId:
|
|||||||
|
|
||||||
let canRemove = false
|
let canRemove = false
|
||||||
|
|
||||||
let exceptionController = notificationPeerExceptionController(context: context, updatedPresentationData: nil, peer: .channel(channel), threadId: threadId, isStories: nil, canRemove: canRemove, defaultSound: defaultSound, edit: true, updatePeerSound: { peerId, sound in
|
let exceptionController = notificationPeerExceptionController(context: context, updatedPresentationData: nil, peer: .channel(channel), threadId: threadId, isStories: nil, canRemove: canRemove, defaultSound: defaultSound, defaultStoriesSound: defaultSound, edit: true, updatePeerSound: { peerId, sound in
|
||||||
let _ = (updatePeerSound(peerId, sound)
|
let _ = (updatePeerSound(peerId, sound)
|
||||||
|> deliverOnMainQueue).start(next: { _ in
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
})
|
})
|
||||||
|
@ -643,11 +643,11 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
|||||||
case .users:
|
case .users:
|
||||||
defaultSound = globalSettings.privateChats.sound._asMessageSound()
|
defaultSound = globalSettings.privateChats.sound._asMessageSound()
|
||||||
case .stories:
|
case .stories:
|
||||||
defaultSound = globalSettings.privateChats.sound._asMessageSound()
|
defaultSound = globalSettings.privateChats.storySettings.sound
|
||||||
isStories = true
|
isStories = true
|
||||||
}
|
}
|
||||||
|
|
||||||
presentControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, threadId: nil, isStories: isStories, canRemove: canRemove, defaultSound: defaultSound, updatePeerSound: { peerId, sound in
|
presentControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, threadId: nil, isStories: isStories, canRemove: canRemove, defaultSound: defaultSound, defaultStoriesSound: defaultSound, updatePeerSound: { peerId, sound in
|
||||||
_ = updatePeerSound(peer.id, sound).start(next: { _ in
|
_ = updatePeerSound(peer.id, sound).start(next: { _ in
|
||||||
updateNotificationsDisposable.set(nil)
|
updateNotificationsDisposable.set(nil)
|
||||||
_ = combineLatest(updatePeerSound(peer.id, sound), context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).start(next: { _, peer in
|
_ = combineLatest(updatePeerSound(peer.id, sound), context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).start(next: { _, peer in
|
||||||
|
@ -91,6 +91,19 @@ public enum NotificationsPeerCategoryEntryTag: ItemListItemTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
||||||
|
enum StableId: Hashable {
|
||||||
|
case enable
|
||||||
|
case enableImportant
|
||||||
|
case importantInfo
|
||||||
|
case optionsHeader
|
||||||
|
case previews
|
||||||
|
case sound
|
||||||
|
case exceptionsHeader
|
||||||
|
case addException
|
||||||
|
case peer(EnginePeer.Id)
|
||||||
|
case removeAllExceptions
|
||||||
|
}
|
||||||
|
|
||||||
case enable(PresentationTheme, String, Bool)
|
case enable(PresentationTheme, String, Bool)
|
||||||
case enableImportant(PresentationTheme, String, Bool)
|
case enableImportant(PresentationTheme, String, Bool)
|
||||||
case importantInfo(PresentationTheme, String)
|
case importantInfo(PresentationTheme, String)
|
||||||
@ -100,7 +113,7 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
|||||||
|
|
||||||
case exceptionsHeader(PresentationTheme, String)
|
case exceptionsHeader(PresentationTheme, String)
|
||||||
case addException(PresentationTheme, String)
|
case addException(PresentationTheme, String)
|
||||||
case exception(Int32, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, EnginePeer, String, TelegramPeerNotificationSettings, Bool, Bool)
|
case exception(Int32, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, PresentationPersonNameOrder, EnginePeer, String, TelegramPeerNotificationSettings, Bool, Bool, Bool)
|
||||||
case removeAllExceptions(PresentationTheme, String)
|
case removeAllExceptions(PresentationTheme, String)
|
||||||
|
|
||||||
var section: ItemListSectionId {
|
var section: ItemListSectionId {
|
||||||
@ -114,7 +127,32 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var stableId: Int32 {
|
var stableId: StableId {
|
||||||
|
switch self {
|
||||||
|
case .enable:
|
||||||
|
return .enable
|
||||||
|
case .enableImportant:
|
||||||
|
return .enableImportant
|
||||||
|
case .importantInfo:
|
||||||
|
return .importantInfo
|
||||||
|
case .optionsHeader:
|
||||||
|
return .optionsHeader
|
||||||
|
case .previews:
|
||||||
|
return .previews
|
||||||
|
case .sound:
|
||||||
|
return .sound
|
||||||
|
case .exceptionsHeader:
|
||||||
|
return .exceptionsHeader
|
||||||
|
case .addException:
|
||||||
|
return .addException
|
||||||
|
case let .exception(_, _, _, _, _, peer, _, _, _, _, _):
|
||||||
|
return .peer(peer.id)
|
||||||
|
case .removeAllExceptions:
|
||||||
|
return .removeAllExceptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var sortIndex: Int32 {
|
||||||
switch self {
|
switch self {
|
||||||
case .enable:
|
case .enable:
|
||||||
return 0
|
return 0
|
||||||
@ -132,10 +170,10 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
|||||||
return 6
|
return 6
|
||||||
case .addException:
|
case .addException:
|
||||||
return 7
|
return 7
|
||||||
case let .exception(index, _, _, _, _, _, _, _, _, _):
|
case let .exception(index, _, _, _, _, _, _, _, _, _, _):
|
||||||
return 8 + index
|
return 100 + index
|
||||||
case .removeAllExceptions:
|
case .removeAllExceptions:
|
||||||
return 100000
|
return 10000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,8 +240,8 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .exception(lhsIndex, lhsTheme, lhsStrings, lhsDateTimeFormat, lhsDisplayNameOrder, lhsPeer, lhsDescription, lhsSettings, lhsEditing, lhsRevealed):
|
case let .exception(lhsIndex, lhsTheme, lhsStrings, lhsDateTimeFormat, lhsDisplayNameOrder, lhsPeer, lhsDescription, lhsSettings, lhsEditing, lhsRevealed, lhsCanRemove):
|
||||||
if case let .exception(rhsIndex, rhsTheme, rhsStrings, rhsDateTimeFormat, rhsDisplayNameOrder, rhsPeer, rhsDescription, rhsSettings, rhsEditing, rhsRevealed) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsDisplayNameOrder == rhsDisplayNameOrder, lhsPeer == rhsPeer, lhsDescription == rhsDescription, lhsSettings == rhsSettings, lhsEditing == rhsEditing, lhsRevealed == rhsRevealed {
|
if case let .exception(rhsIndex, rhsTheme, rhsStrings, rhsDateTimeFormat, rhsDisplayNameOrder, rhsPeer, rhsDescription, rhsSettings, rhsEditing, rhsRevealed, rhsCanRemove) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsDisplayNameOrder == rhsDisplayNameOrder, lhsPeer == rhsPeer, lhsDescription == rhsDescription, lhsSettings == rhsSettings, lhsEditing == rhsEditing, lhsRevealed == rhsRevealed, lhsCanRemove == rhsCanRemove {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@ -219,7 +257,7 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static func <(lhs: NotificationsPeerCategoryEntry, rhs: NotificationsPeerCategoryEntry) -> Bool {
|
static func <(lhs: NotificationsPeerCategoryEntry, rhs: NotificationsPeerCategoryEntry) -> Bool {
|
||||||
return lhs.stableId < rhs.stableId
|
return lhs.sortIndex < rhs.sortIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||||
@ -251,8 +289,8 @@ private enum NotificationsPeerCategoryEntry: ItemListNodeEntry {
|
|||||||
return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.plusIconImage(theme), title: text, sectionId: self.section, height: .peerList, color: .accent, editing: false, action: {
|
return ItemListPeerActionItem(presentationData: presentationData, icon: PresentationResourcesItemList.plusIconImage(theme), title: text, sectionId: self.section, height: .peerList, color: .accent, editing: false, action: {
|
||||||
arguments.addException()
|
arguments.addException()
|
||||||
})
|
})
|
||||||
case let .exception(_, _, _, dateTimeFormat, nameDisplayOrder, peer, description, _, editing, revealed):
|
case let .exception(_, _, _, dateTimeFormat, nameDisplayOrder, peer, description, _, editing, revealed, canRemove):
|
||||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .text(description, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: true, editing: editing, revealed: revealed), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .text(description, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: canRemove, editing: canRemove && editing, revealed: canRemove && revealed), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||||
arguments.openException(peer)
|
arguments.openException(peer)
|
||||||
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||||
arguments.updateRevealedPeerId(peerId)
|
arguments.updateRevealedPeerId(peerId)
|
||||||
@ -371,11 +409,13 @@ private func notificationsPeerCategoryEntries(category: NotificationsPeerCategor
|
|||||||
|
|
||||||
for (_, value) in sortedExceptions {
|
for (_, value) in sortedExceptions {
|
||||||
if !value.peer.isDeleted {
|
if !value.peer.isDeleted {
|
||||||
|
var canRemove = true
|
||||||
var title: String = ""
|
var title: String = ""
|
||||||
|
|
||||||
if automaticSet.contains(value.peer.id) {
|
if automaticSet.contains(value.peer.id) {
|
||||||
//TODO:localize
|
//TODO:localize
|
||||||
title = "\(presentationData.strings.Notification_Exceptions_AlwaysOn) (automatic)"
|
title = "\(presentationData.strings.Notification_Exceptions_AlwaysOn) (automatic)"
|
||||||
|
canRemove = false
|
||||||
} else {
|
} else {
|
||||||
if case .stories = category {
|
if case .stories = category {
|
||||||
var muted = false
|
var muted = false
|
||||||
@ -468,7 +508,7 @@ private func notificationsPeerCategoryEntries(category: NotificationsPeerCategor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
existingPeerIds.insert(value.peer.id)
|
existingPeerIds.insert(value.peer.id)
|
||||||
entries.append(.exception(Int32(index), presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, value.peer, title, value.settings, state.editing, state.revealedPeerId == value.peer.id))
|
entries.append(.exception(Int32(index), presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, value.peer, title, value.settings, state.editing, state.revealedPeerId == value.peer.id, canRemove))
|
||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,6 +574,10 @@ private final class NotificationExceptionState : Equatable {
|
|||||||
return NotificationExceptionState(mode: mode.withUpdatedPeerStorySound(peer, sound), revealedPeerId: self.revealedPeerId, editing: self.editing)
|
return NotificationExceptionState(mode: mode.withUpdatedPeerStorySound(peer, sound), revealedPeerId: self.revealedPeerId, editing: self.editing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeStoryPeerIfDefault(id: EnginePeer.Id) -> NotificationExceptionState {
|
||||||
|
return NotificationExceptionState(mode: mode.removeStoryPeerIfDefault(id: id), revealedPeerId: self.revealedPeerId, editing: self.editing)
|
||||||
|
}
|
||||||
|
|
||||||
static func == (lhs: NotificationExceptionState, rhs: NotificationExceptionState) -> Bool {
|
static func == (lhs: NotificationExceptionState, rhs: NotificationExceptionState) -> Bool {
|
||||||
return lhs.mode == rhs.mode && lhs.revealedPeerId == rhs.revealedPeerId && lhs.editing == rhs.editing
|
return lhs.mode == rhs.mode && lhs.revealedPeerId == rhs.revealedPeerId && lhs.editing == rhs.editing
|
||||||
}
|
}
|
||||||
@ -655,11 +699,11 @@ public func notificationsPeerCategoryController(context: AccountContext, categor
|
|||||||
case .users:
|
case .users:
|
||||||
defaultSound = globalSettings.privateChats.sound._asMessageSound()
|
defaultSound = globalSettings.privateChats.sound._asMessageSound()
|
||||||
case .stories:
|
case .stories:
|
||||||
defaultSound = globalSettings.privateChats.sound._asMessageSound()
|
defaultSound = globalSettings.privateChats.storySettings.sound
|
||||||
isStories = true
|
isStories = true
|
||||||
}
|
}
|
||||||
|
|
||||||
pushControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, threadId: nil, isStories: isStories, canRemove: canRemove, defaultSound: defaultSound, updatePeerSound: { peerId, sound in
|
pushControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, threadId: nil, isStories: isStories, canRemove: canRemove, defaultSound: defaultSound, defaultStoriesSound: defaultSound, updatePeerSound: { peerId, sound in
|
||||||
_ = updatePeerSound(peer.id, sound).start(next: { _ in
|
_ = updatePeerSound(peer.id, sound).start(next: { _ in
|
||||||
updateNotificationsDisposable.set(nil)
|
updateNotificationsDisposable.set(nil)
|
||||||
_ = combineLatest(updatePeerSound(peer.id, sound), context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).start(next: { _, peer in
|
_ = combineLatest(updatePeerSound(peer.id, sound), context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) |> deliverOnMainQueue).start(next: { _, peer in
|
||||||
@ -732,7 +776,9 @@ public func notificationsPeerCategoryController(context: AccountContext, categor
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateState { value in
|
updateState { value in
|
||||||
return value.withUpdatedPeerStorySound(peer, .default).withUpdatedPeerStoriesMuted(peer, .default).withUpdatedPeerStoriesHideSender(peer, .default)
|
var value = value.withUpdatedPeerStorySound(peer, .default).withUpdatedPeerStoriesMuted(peer, .default).withUpdatedPeerStoriesHideSender(peer, .default)
|
||||||
|
value = value.removeStoryPeerIfDefault(id: peer.id)
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
updateNotificationsView({})
|
updateNotificationsView({})
|
||||||
})
|
})
|
||||||
@ -858,6 +904,7 @@ public func notificationsPeerCategoryController(context: AccountContext, categor
|
|||||||
var state = state
|
var state = state
|
||||||
for value in values {
|
for value in values {
|
||||||
state = state.withUpdatedPeerStorySound(value.peer, .default).withUpdatedPeerStoriesMuted(value.peer, .default).withUpdatedPeerStoriesHideSender(value.peer, .default)
|
state = state.withUpdatedPeerStorySound(value.peer, .default).withUpdatedPeerStoriesMuted(value.peer, .default).withUpdatedPeerStoriesHideSender(value.peer, .default)
|
||||||
|
state = state.removeStoryPeerIfDefault(id: value.peer.id)
|
||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
@ -900,7 +947,9 @@ public func notificationsPeerCategoryController(context: AccountContext, categor
|
|||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
updateNotificationsDisposable.set(nil)
|
updateNotificationsDisposable.set(nil)
|
||||||
updateState { value in
|
updateState { value in
|
||||||
return value.withUpdatedPeerStorySound(peer, .default).withUpdatedPeerStoriesMuted(peer, .default).withUpdatedPeerStoriesHideSender(peer, .default)
|
var value = value.withUpdatedPeerStorySound(peer, .default).withUpdatedPeerStoriesMuted(peer, .default).withUpdatedPeerStoriesHideSender(peer, .default)
|
||||||
|
value = value.removeStoryPeerIfDefault(id: peer.id)
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
let _ = (context.engine.peers.removeCustomStoryNotificationSettings(peerIds: [peer.id])
|
let _ = (context.engine.peers.removeCustomStoryNotificationSettings(peerIds: [peer.id])
|
||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
|
@ -466,7 +466,7 @@ public func threadNotificationExceptionsScreen(context: AccountContext, peerId:
|
|||||||
let canRemove = true
|
let canRemove = true
|
||||||
let defaultSound: PeerMessageSound = globalSettings.groupChats.sound._asMessageSound()
|
let defaultSound: PeerMessageSound = globalSettings.groupChats.sound._asMessageSound()
|
||||||
|
|
||||||
pushControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, customTitle: item.info.title, threadId: item.threadId, isStories: nil, canRemove: canRemove, defaultSound: defaultSound, updatePeerSound: { _, sound in
|
pushControllerImpl?(notificationPeerExceptionController(context: context, peer: peer, customTitle: item.info.title, threadId: item.threadId, isStories: nil, canRemove: canRemove, defaultSound: defaultSound, defaultStoriesSound: defaultSound, updatePeerSound: { _, sound in
|
||||||
let _ = (updateThreadSound(item.threadId, sound)
|
let _ = (updateThreadSound(item.threadId, sound)
|
||||||
|> deliverOnMainQueue).start(next: { _ in
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
updateState { value in
|
updateState { value in
|
||||||
|
@ -368,6 +368,25 @@ public enum NotificationExceptionMode : Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func removeStoryPeerIfDefault(id: EnginePeer.Id) -> NotificationExceptionMode {
|
||||||
|
switch self {
|
||||||
|
case let .stories(values):
|
||||||
|
if let settings = values[id]?.settings {
|
||||||
|
if settings.storySettings == .default {
|
||||||
|
var values = values
|
||||||
|
values.removeValue(forKey: id)
|
||||||
|
return .stories(values)
|
||||||
|
} else {
|
||||||
|
return .stories(values)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .stories(values)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public var peerIds: [EnginePeer.Id] {
|
public var peerIds: [EnginePeer.Id] {
|
||||||
switch self {
|
switch self {
|
||||||
case let .users(settings), let .groups(settings), let .channels(settings), let .stories(settings):
|
case let .users(settings), let .groups(settings), let .channels(settings), let .stories(settings):
|
||||||
@ -735,6 +754,8 @@ private func notificationPeerExceptionEntries(presentationData: PresentationData
|
|||||||
}
|
}
|
||||||
|
|
||||||
if displaySounds {
|
if displaySounds {
|
||||||
|
let defaultSound = isStories == true ? state.defaultStoriesSound : state.defaultSound
|
||||||
|
|
||||||
entries.append(.cloudHeader(index: index, text: presentationData.strings.Notifications_TelegramTones))
|
entries.append(.cloudHeader(index: index, text: presentationData.strings.Notifications_TelegramTones))
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
@ -765,7 +786,7 @@ private func notificationPeerExceptionEntries(presentationData: PresentationData
|
|||||||
|
|
||||||
index = 3000
|
index = 3000
|
||||||
|
|
||||||
entries.append(.default(index: index, section: .soundModern, theme: presentationData.theme, text: localizedPeerNotificationSoundString(strings: presentationData.strings, notificationSoundList: notificationSoundList, sound: .default, default: state.defaultSound), selected: selectedSound == .default))
|
entries.append(.default(index: index, section: .soundModern, theme: presentationData.theme, text: localizedPeerNotificationSoundString(strings: presentationData.strings, notificationSoundList: notificationSoundList, sound: .default, default: defaultSound), selected: selectedSound == .default))
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
entries.append(.none(index: index, section: .soundModern, theme: presentationData.theme, text: localizedPeerNotificationSoundString(strings: presentationData.strings, notificationSoundList: notificationSoundList, sound: .none), selected: selectedSound == .none))
|
entries.append(.none(index: index, section: .soundModern, theme: presentationData.theme, text: localizedPeerNotificationSoundString(strings: presentationData.strings, notificationSoundList: notificationSoundList, sound: .none), selected: selectedSound == .none))
|
||||||
@ -797,6 +818,7 @@ private struct NotificationExceptionPeerState : Equatable {
|
|||||||
var mode: NotificationPeerExceptionSwitcher
|
var mode: NotificationPeerExceptionSwitcher
|
||||||
var defaultSound: PeerMessageSound
|
var defaultSound: PeerMessageSound
|
||||||
var displayPreviews: NotificationPeerExceptionSwitcher
|
var displayPreviews: NotificationPeerExceptionSwitcher
|
||||||
|
var defaultStoriesSound: PeerMessageSound
|
||||||
var storiesMuted: NotificationPeerExceptionSwitcher
|
var storiesMuted: NotificationPeerExceptionSwitcher
|
||||||
var selectedStoriesSound: PeerMessageSound
|
var selectedStoriesSound: PeerMessageSound
|
||||||
var storiesHideSender: NotificationPeerExceptionSwitcher
|
var storiesHideSender: NotificationPeerExceptionSwitcher
|
||||||
@ -827,6 +849,7 @@ private struct NotificationExceptionPeerState : Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.defaultSound = .default
|
self.defaultSound = .default
|
||||||
|
self.defaultStoriesSound = .default
|
||||||
self.removedSounds = []
|
self.removedSounds = []
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,6 +859,7 @@ private struct NotificationExceptionPeerState : Equatable {
|
|||||||
mode: NotificationPeerExceptionSwitcher,
|
mode: NotificationPeerExceptionSwitcher,
|
||||||
defaultSound: PeerMessageSound,
|
defaultSound: PeerMessageSound,
|
||||||
displayPreviews: NotificationPeerExceptionSwitcher,
|
displayPreviews: NotificationPeerExceptionSwitcher,
|
||||||
|
defaultStoriesSound: PeerMessageSound,
|
||||||
storiesMuted: NotificationPeerExceptionSwitcher,
|
storiesMuted: NotificationPeerExceptionSwitcher,
|
||||||
selectedStoriesSound: PeerMessageSound,
|
selectedStoriesSound: PeerMessageSound,
|
||||||
storiesHideSender: NotificationPeerExceptionSwitcher,
|
storiesHideSender: NotificationPeerExceptionSwitcher,
|
||||||
@ -846,6 +870,7 @@ private struct NotificationExceptionPeerState : Equatable {
|
|||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.defaultSound = defaultSound
|
self.defaultSound = defaultSound
|
||||||
self.displayPreviews = displayPreviews
|
self.displayPreviews = displayPreviews
|
||||||
|
self.defaultStoriesSound = defaultStoriesSound
|
||||||
self.storiesMuted = storiesMuted
|
self.storiesMuted = storiesMuted
|
||||||
self.selectedStoriesSound = selectedStoriesSound
|
self.selectedStoriesSound = selectedStoriesSound
|
||||||
self.storiesHideSender = storiesHideSender
|
self.storiesHideSender = storiesHideSender
|
||||||
@ -862,6 +887,7 @@ public func notificationPeerExceptionController(
|
|||||||
isStories: Bool?,
|
isStories: Bool?,
|
||||||
canRemove: Bool,
|
canRemove: Bool,
|
||||||
defaultSound: PeerMessageSound,
|
defaultSound: PeerMessageSound,
|
||||||
|
defaultStoriesSound: PeerMessageSound,
|
||||||
edit: Bool = false,
|
edit: Bool = false,
|
||||||
updatePeerSound: @escaping(EnginePeer.Id, PeerMessageSound) -> Void,
|
updatePeerSound: @escaping(EnginePeer.Id, PeerMessageSound) -> Void,
|
||||||
updatePeerNotificationInterval: @escaping(EnginePeer.Id, Int32?) -> Void,
|
updatePeerNotificationInterval: @escaping(EnginePeer.Id, Int32?) -> Void,
|
||||||
@ -894,7 +920,7 @@ public func notificationPeerExceptionController(
|
|||||||
let _ = (context.engine.peers.notificationSoundList()
|
let _ = (context.engine.peers.notificationSoundList()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { notificationSoundList in
|
|> deliverOnMainQueue).start(next: { notificationSoundList in
|
||||||
playSoundDisposable.set(playSound(context: context, notificationSoundList: notificationSoundList, sound: sound, defaultSound: state.defaultSound).start())
|
playSoundDisposable.set(playSound(context: context, notificationSoundList: notificationSoundList, sound: sound, defaultSound: state.defaultStoriesSound).start())
|
||||||
})
|
})
|
||||||
|
|
||||||
var state = state
|
var state = state
|
||||||
@ -943,7 +969,7 @@ public func notificationPeerExceptionController(
|
|||||||
let _ = (context.engine.peers.notificationSoundList()
|
let _ = (context.engine.peers.notificationSoundList()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { notificationSoundList in
|
|> deliverOnMainQueue).start(next: { notificationSoundList in
|
||||||
playSoundDisposable.set(playSound(context: context, notificationSoundList: notificationSoundList, sound: sound, defaultSound: state.defaultSound).start())
|
playSoundDisposable.set(playSound(context: context, notificationSoundList: notificationSoundList, sound: sound, defaultSound: state.defaultStoriesSound).start())
|
||||||
})
|
})
|
||||||
|
|
||||||
var state = state
|
var state = state
|
||||||
@ -972,6 +998,7 @@ public func notificationPeerExceptionController(
|
|||||||
|
|
||||||
var state = NotificationExceptionPeerState(canRemove: canRemove, notifications: effectiveSettings._asNotificationSettings())
|
var state = NotificationExceptionPeerState(canRemove: canRemove, notifications: effectiveSettings._asNotificationSettings())
|
||||||
state.defaultSound = defaultSound
|
state.defaultSound = defaultSound
|
||||||
|
state.defaultStoriesSound = defaultStoriesSound
|
||||||
let _ = stateValue.swap(state)
|
let _ = stateValue.swap(state)
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
@ -1003,8 +1003,15 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
guard let component = self.component else {
|
guard let component = self.component else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if component.slice.peer.id == component.context.account.peerId {
|
|
||||||
} else {
|
var canReply = true
|
||||||
|
if component.slice.peer.isService {
|
||||||
|
canReply = false
|
||||||
|
} else if case .unsupported = component.slice.item.storyItem.media {
|
||||||
|
canReply = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if canReply {
|
||||||
if let inputPanelView = self.inputPanel.view as? MessageInputPanelComponent.View {
|
if let inputPanelView = self.inputPanel.view as? MessageInputPanelComponent.View {
|
||||||
return { [weak inputPanelView] in
|
return { [weak inputPanelView] in
|
||||||
inputPanelView?.activateInput()
|
inputPanelView?.activateInput()
|
||||||
|
@ -4750,7 +4750,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
|
|
||||||
let canRemove = false
|
let canRemove = false
|
||||||
|
|
||||||
let exceptionController = notificationPeerExceptionController(context: context, updatedPresentationData: strongSelf.controller?.updatedPresentationData, peer: EnginePeer(peer), threadId: threadId, isStories: nil, canRemove: canRemove, defaultSound: defaultSound, edit: true, updatePeerSound: { peerId, sound in
|
let exceptionController = notificationPeerExceptionController(context: context, updatedPresentationData: strongSelf.controller?.updatedPresentationData, peer: EnginePeer(peer), threadId: threadId, isStories: nil, canRemove: canRemove, defaultSound: defaultSound, defaultStoriesSound: globalSettings.privateChats.storySettings.sound, edit: true, updatePeerSound: { peerId, sound in
|
||||||
let _ = (updatePeerSound(peer.id, sound)
|
let _ = (updatePeerSound(peer.id, sound)
|
||||||
|> deliverOnMainQueue).start(next: { _ in
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user