mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Preload sounds
This commit is contained in:
parent
3b67110f83
commit
333d34e4b7
@ -377,6 +377,7 @@ public func notificationSoundSelectionController(context: AccountContext, update
|
|||||||
|
|
||||||
let playSoundDisposable = MetaDisposable()
|
let playSoundDisposable = MetaDisposable()
|
||||||
let soundActionDisposable = MetaDisposable()
|
let soundActionDisposable = MetaDisposable()
|
||||||
|
let fetchedSoundsDisposable = ensureDownloadedNotificationSoundList(postbox: context.account.postbox).start()
|
||||||
|
|
||||||
let arguments = NotificationSoundSelectionArguments(account: context.account, selectSound: { sound in
|
let arguments = NotificationSoundSelectionArguments(account: context.account, selectSound: { sound in
|
||||||
updateState { state in
|
updateState { state in
|
||||||
@ -422,6 +423,7 @@ public func notificationSoundSelectionController(context: AccountContext, update
|
|||||||
let controller = ItemListController(context: context, state: signal |> afterDisposed {
|
let controller = ItemListController(context: context, state: signal |> afterDisposed {
|
||||||
playSoundDisposable.dispose()
|
playSoundDisposable.dispose()
|
||||||
soundActionDisposable.dispose()
|
soundActionDisposable.dispose()
|
||||||
|
fetchedSoundsDisposable.dispose()
|
||||||
})
|
})
|
||||||
controller.enableInteractiveDismiss = true
|
controller.enableInteractiveDismiss = true
|
||||||
if isModal {
|
if isModal {
|
||||||
|
@ -694,6 +694,7 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
private let presentationDataValue = Promise<(PresentationTheme, PresentationStrings)>()
|
private let presentationDataValue = Promise<(PresentationTheme, PresentationStrings)>()
|
||||||
private var listDisposable: Disposable?
|
private var listDisposable: Disposable?
|
||||||
|
private var fetchedSoundsDisposable: Disposable?
|
||||||
|
|
||||||
private var arguments: NotificationExceptionArguments?
|
private var arguments: NotificationExceptionArguments?
|
||||||
private let stateValue: Atomic<NotificationExceptionState>
|
private let stateValue: Atomic<NotificationExceptionState>
|
||||||
@ -996,12 +997,15 @@ final class NotificationExceptionsControllerNode: ViewControllerTracingNode {
|
|||||||
|
|
||||||
self?.enqueueTransition(transition)
|
self?.enqueueTransition(transition)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
self.fetchedSoundsDisposable = ensureDownloadedNotificationSoundList(postbox: context.account.postbox).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.listDisposable?.dispose()
|
self.listDisposable?.dispose()
|
||||||
self.navigationActionDisposable.dispose()
|
self.navigationActionDisposable.dispose()
|
||||||
self.updateNotificationsDisposable.dispose()
|
self.updateNotificationsDisposable.dispose()
|
||||||
|
self.fetchedSoundsDisposable?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePresentationData(_ presentationData: PresentationData) {
|
func updatePresentationData(_ presentationData: PresentationData) {
|
||||||
|
@ -139,6 +139,35 @@ func _internal_setCachedNotificationSoundList(transaction: Transaction, notifica
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func ensureDownloadedNotificationSoundList(postbox: Postbox) -> Signal<Never, NoError> {
|
||||||
|
return postbox.transaction { transaction -> Signal<Never, NoError> in
|
||||||
|
var signals: [Signal<Never, NoError>] = []
|
||||||
|
|
||||||
|
if let notificationSoundList = _internal_cachedNotificationSoundList(transaction: transaction) {
|
||||||
|
var resources: [MediaResource] = []
|
||||||
|
|
||||||
|
for sound in notificationSoundList.sounds {
|
||||||
|
resources.append(sound.file.resource)
|
||||||
|
}
|
||||||
|
|
||||||
|
for resource in resources {
|
||||||
|
signals.append(
|
||||||
|
fetchedMediaResource(mediaBox: postbox.mediaBox, reference: .standalone(resource: resource))
|
||||||
|
|> ignoreValues
|
||||||
|
|> `catch` { _ -> Signal<Never, NoError> in
|
||||||
|
return .complete()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return combineLatest(signals)
|
||||||
|
|> ignoreValues
|
||||||
|
}
|
||||||
|
|> switchToLatest
|
||||||
|
|> ignoreValues
|
||||||
|
}
|
||||||
|
|
||||||
private func pollNotificationSoundList(postbox: Postbox, network: Network) -> Signal<Never, NoError> {
|
private func pollNotificationSoundList(postbox: Postbox, network: Network) -> Signal<Never, NoError> {
|
||||||
return Signal<Never, NoError> { subscriber in
|
return Signal<Never, NoError> { subscriber in
|
||||||
let signal: Signal<Never, NoError> = _internal_cachedNotificationSoundList(postbox: postbox)
|
let signal: Signal<Never, NoError> = _internal_cachedNotificationSoundList(postbox: postbox)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user