mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-15 18:59:54 +00:00
Fixed contact import data format
Additional fixes for music in background when switching accounts
This commit is contained in:
parent
b0815c344e
commit
02836dc2d8
@ -483,7 +483,7 @@ private final class DeviceContactDataManagerImpl {
|
||||
var importableContactData: [String: (DeviceContactStableId, ImportableDeviceContactData)] = [:]
|
||||
for (stableId, basicData) in self.stableIdToBasicContactData {
|
||||
for phoneNumber in basicData.phoneNumbers {
|
||||
let normalizedNumber = formatPhoneNumber(phoneNumber.value)
|
||||
let normalizedNumber = phoneNumber.value
|
||||
var replace = false
|
||||
if let current = importableContactData[normalizedNumber] {
|
||||
if stableId < current.0 {
|
||||
|
||||
@ -431,12 +431,10 @@ final class ManagedAudioRecorderContext {
|
||||
self.beganWithTone(false)
|
||||
}
|
||||
|
||||
self.audioUnit.with { audioUnit -> Void in
|
||||
if let audioUnit = audioUnit {
|
||||
guard AudioOutputUnitStart(audioUnit) == noErr else {
|
||||
self.stop()
|
||||
return
|
||||
}
|
||||
if let audioUnit = self.audioUnit.with({ $0 }) {
|
||||
guard AudioOutputUnitStart(audioUnit) == noErr else {
|
||||
self.stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,15 @@ public final class MediaManager: NSObject {
|
||||
return sharedAudioSession
|
||||
}
|
||||
|
||||
private let isCurrentPromise = ValuePromise<Bool>(false)
|
||||
var isCurrent: Bool = false {
|
||||
didSet {
|
||||
if self.isCurrent != oldValue {
|
||||
self.isCurrentPromise.set(self.isCurrent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private let queue = Queue.mainQueue()
|
||||
|
||||
private let postbox: Postbox
|
||||
@ -370,8 +379,11 @@ public final class MediaManager: NSObject {
|
||||
}
|
||||
|
||||
self.globalAudioSessionForegroundDisposable.set((shouldKeepAudioSession |> deliverOnMainQueue).start(next: { [weak self] value in
|
||||
if value {
|
||||
self?.audioSession.dropAll()
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
if strongSelf.isCurrent && value {
|
||||
strongSelf.audioSession.dropAll()
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
@ -105,6 +105,12 @@ public final class TelegramApplicationContext {
|
||||
|
||||
private var storedPassword: (String, CFAbsoluteTime, SwiftSignalKit.Timer)?
|
||||
|
||||
public var isCurrent: Bool = false {
|
||||
didSet {
|
||||
self.mediaManager?.isCurrent = self.isCurrent
|
||||
}
|
||||
}
|
||||
|
||||
public init(applicationBindings: TelegramApplicationBindings, accountManager: AccountManager, account: Account?, initialPresentationDataAndSettings: InitialPresentationDataAndSettings, postbox: Postbox) {
|
||||
if account != nil {
|
||||
self.mediaManager = MediaManager(postbox: postbox, inForeground: applicationBindings.applicationInForeground)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user