Peer sound and message removal update

This commit is contained in:
Ali
2022-03-30 01:22:44 +04:00
parent 0e55dd7db7
commit 235302c7c4
63 changed files with 3906 additions and 1934 deletions

View File

@@ -287,7 +287,7 @@ public enum NotificationExceptionMode : Equatable {
}
}
private func notificationsExceptionEntries(presentationData: PresentationData, state: NotificationExceptionState, query: String? = nil, foundPeers: [RenderedPeer] = []) -> [NotificationExceptionEntry] {
private func notificationsExceptionEntries(presentationData: PresentationData, notificationSoundList: NotificationSoundList?, state: NotificationExceptionState, query: String? = nil, foundPeers: [RenderedPeer] = []) -> [NotificationExceptionEntry] {
var entries: [NotificationExceptionEntry] = []
if !state.isSearchMode {
@@ -361,7 +361,7 @@ private func notificationsExceptionEntries(presentationData: PresentationData, s
case .default:
break
default:
let soundName = localizedPeerNotificationSoundString(strings: presentationData.strings, sound: value.settings.messageSound)
let soundName = localizedPeerNotificationSoundString(strings: presentationData.strings, notificationSoundList: notificationSoundList, sound: value.settings.messageSound)
title += (title.isEmpty ? presentationData.strings.Notification_Exceptions_Sound(soundName).string : ", \(presentationData.strings.Notification_Exceptions_Sound(soundName).string)")
}
switch value.settings.displayPreviews {
@@ -975,8 +975,8 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
let previousEntriesHolder = Atomic<([NotificationExceptionEntry], PresentationTheme, PresentationStrings)?>(value: nil)
self.listDisposable = (combineLatest(context.sharedContext.presentationData, statePromise.get(), preferences) |> deliverOnMainQueue).start(next: { [weak self] (presentationData, state, prefs) in
let entries = notificationsExceptionEntries(presentationData: presentationData, state: state)
self.listDisposable = (combineLatest(context.sharedContext.presentationData, statePromise.get(), preferences, context.engine.peers.notificationSoundList()) |> deliverOnMainQueue).start(next: { [weak self] presentationData, state, prefs, notificationSoundList in
let entries = notificationsExceptionEntries(presentationData: presentationData, notificationSoundList: notificationSoundList, state: state)
let previousEntriesAndPresentationData = previousEntriesHolder.swap((entries, presentationData.theme, presentationData.strings))
updateCanStartEditing(state.mode.peerIds.isEmpty ? nil : state.editing)
@@ -1233,16 +1233,16 @@ private final class NotificationExceptionsSearchContainerNode: SearchDisplayCont
|> distinctUntilChanged
let searchSignal = stateQuery
|> mapToSignal { query -> Signal<(PresentationData, (NotificationExceptionState, String?), PreferencesView, [RenderedPeer]), NoError> in
|> mapToSignal { query -> Signal<(PresentationData, NotificationSoundList?, (NotificationExceptionState, String?), PreferencesView, [RenderedPeer]), NoError> in
var contactsSignal: Signal<[RenderedPeer], NoError> = .single([])
if let query = query {
contactsSignal = context.account.postbox.searchPeers(query: query)
}
return combineLatest(context.sharedContext.presentationData, stateAndPeers, preferences, contactsSignal)
return combineLatest(context.sharedContext.presentationData, context.engine.peers.notificationSoundList(), stateAndPeers, preferences, contactsSignal)
}
self.searchDisposable.set((searchSignal
|> deliverOnMainQueue).start(next: { [weak self] (presentationData, state, prefs, foundPeers) in
let entries = notificationsExceptionEntries(presentationData: presentationData, state: state.0, query: state.1, foundPeers: foundPeers)
|> deliverOnMainQueue).start(next: { [weak self] presentationData, notificationSoundList, state, prefs, foundPeers in
let entries = notificationsExceptionEntries(presentationData: presentationData, notificationSoundList: notificationSoundList, state: state.0, query: state.1, foundPeers: foundPeers)
let previousEntriesAndPresentationData = previousEntriesHolder.swap((entries, presentationData.theme, presentationData.strings))
let transition = preparedNotificationExceptionsSearchContainerTransition(presentationData: ItemListPresentationData(presentationData), from: previousEntriesAndPresentationData?.0 ?? [], to: entries, arguments: arguments, isSearching: state.1 != nil && !state.1!.isEmpty, forceUpdate: previousEntriesAndPresentationData?.1 !== presentationData.theme || previousEntriesAndPresentationData?.2 !== presentationData.strings)