Fixed contact import data format

Additional fixes for music in background when switching accounts
This commit is contained in:
Peter 2018-10-10 20:13:52 +03:00
parent b0815c344e
commit 02836dc2d8
4 changed files with 25 additions and 9 deletions

View File

@ -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 {

View File

@ -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
}
}
}

View File

@ -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()
}
}))
}

View File

@ -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)