mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 12:17:53 +00:00
no message
This commit is contained in:
parent
501de4a5fe
commit
bcc7d11fdb
@ -885,6 +885,16 @@ public class Account {
|
||||
|
||||
public let notificationToken = Promise<Data>()
|
||||
public let voipToken = Promise<Data>()
|
||||
|
||||
private var notificationTokensVersionValue = 0 {
|
||||
didSet {
|
||||
self.notificationTokensVersionPromise.set(self.notificationTokensVersionValue)
|
||||
}
|
||||
}
|
||||
func updateNotificationTokensVersion() {
|
||||
self.notificationTokensVersionValue += 1
|
||||
}
|
||||
private let notificationTokensVersionPromise = ValuePromise<Int>(0)
|
||||
private let notificationTokenDisposable = MetaDisposable()
|
||||
private let voipTokenDisposable = MetaDisposable()
|
||||
|
||||
@ -1017,9 +1027,9 @@ public class Account {
|
||||
|
||||
self.networkTypeValue.set(currentNetworkType())
|
||||
|
||||
let appliedNotificationToken = self.notificationToken.get()
|
||||
|> distinctUntilChanged
|
||||
|> mapToSignal { token -> Signal<Void, NoError> in
|
||||
let appliedNotificationToken = combineLatest(self.notificationToken.get(), self.notificationTokensVersionPromise.get())
|
||||
|> distinctUntilChanged(isEqual: { $0 == $1 })
|
||||
|> mapToSignal { token, _ -> Signal<Void, NoError> in
|
||||
var tokenString = ""
|
||||
token.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
|
||||
for i in 0 ..< token.count {
|
||||
@ -1044,9 +1054,9 @@ public class Account {
|
||||
}
|
||||
self.notificationTokenDisposable.set(appliedNotificationToken.start())
|
||||
|
||||
let appliedVoipToken = self.voipToken.get()
|
||||
|> distinctUntilChanged
|
||||
|> mapToSignal { token -> Signal<Void, NoError> in
|
||||
let appliedVoipToken = combineLatest(self.voipToken.get(), self.notificationTokensVersionPromise.get())
|
||||
|> distinctUntilChanged(isEqual: { $0 == $1 })
|
||||
|> mapToSignal { token, _ -> Signal<Void, NoError> in
|
||||
var tokenString = ""
|
||||
token.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Void in
|
||||
for i in 0 ..< token.count {
|
||||
|
||||
@ -261,7 +261,8 @@ private final class MultipartUploadManager {
|
||||
case let .data(data):
|
||||
fileData = data
|
||||
}
|
||||
let partData = self.state.transformHeader(data: fileData!.subdata(in: partOffset ..< (partOffset + partSize)))
|
||||
if let fileData = fileData {
|
||||
let partData = self.state.transformHeader(data: fileData.subdata(in: partOffset ..< (partOffset + partSize)))
|
||||
var currentBigTotalParts: Int? = nil
|
||||
if self.bigParts {
|
||||
let totalParts = (resourceData.size / self.defaultPartSize) + (resourceData.size % self.defaultPartSize == 0 ? 0 : 1)
|
||||
@ -279,6 +280,7 @@ private final class MultipartUploadManager {
|
||||
strongSelf.checkState()
|
||||
}
|
||||
}))
|
||||
}
|
||||
case .uploading:
|
||||
break
|
||||
}
|
||||
|
||||
@ -29,19 +29,23 @@ public enum TerminateSessionError {
|
||||
|
||||
public func terminateAccountSession(account: Account, hash: Int64) -> Signal<Void, TerminateSessionError> {
|
||||
return account.network.request(Api.functions.account.resetAuthorization(hash: hash))
|
||||
|> map {_ in}
|
||||
|> mapError { error -> TerminateSessionError in
|
||||
if error.errorCode == 406 {
|
||||
return .freshReset
|
||||
}
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Void, TerminateSessionError> in
|
||||
account.updateNotificationTokensVersion()
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
||||
public func terminateOtherAccountSessions(account: Account) -> Signal<Void, NoError> {
|
||||
return account.network.request(Api.functions.auth.resetAuthorizations())
|
||||
|> retryRequest
|
||||
|> mapToSignal { _ -> Signal<Void, NoError> in
|
||||
account.updateNotificationTokensVersion()
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user