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