Merge branch 'master' of gitlab.com:peter-iakovlev/TelegramCore

This commit is contained in:
Ilya Laktyushin
2019-01-17 22:04:52 +04:00
3 changed files with 27 additions and 11 deletions

View File

@@ -369,11 +369,13 @@ public final class AccountStateManager {
|> take(1)
|> mapToSignal { state -> Signal<(Api.updates.Difference?, AccountReplayedFinalState?), NoError> in
if let authorizedState = state.state {
var ptsTotalLimit: Int32 = 10000
var flags: Int32 = 0
var ptsTotalLimit: Int32? = nil
#if DEBUG
//ptsTotalLimit = 10
//flags = 1 << 0
//ptsTotalLimit = 1000
#endif
let request = network.request(Api.functions.updates.getDifference(flags: 1 << 0, pts: authorizedState.pts, ptsTotalLimit: ptsTotalLimit, date: authorizedState.date, qts: authorizedState.qts))
let request = network.request(Api.functions.updates.getDifference(flags: flags, pts: authorizedState.pts, ptsTotalLimit: ptsTotalLimit, date: authorizedState.date, qts: authorizedState.qts))
|> retryRequest
return request

View File

@@ -110,11 +110,11 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
let chats = network.request(Api.functions.account.getNotifySettings(peer: Api.InputNotifyPeer.inputNotifyChats))
let users = network.request(Api.functions.account.getNotifySettings(peer: Api.InputNotifyPeer.inputNotifyUsers))
let channels = network.request(Api.functions.account.getNotifySettings(peer: Api.InputNotifyPeer.inputNotifyBroadcasts))
let contactsJoined = network.request(Api.functions.account.getContactSignUpNotification())
let contactsJoinedMuted = network.request(Api.functions.account.getContactSignUpNotification())
return combineLatest(chats, users, channels, contactsJoined)
return combineLatest(chats, users, channels, contactsJoinedMuted)
|> retryRequest
|> map { chats, users, channels, contactsJoined in
|> map { chats, users, channels, contactsJoinedMuted in
let chatsSettings: MessageNotificationSettings
switch chats {
case .peerNotifySettingsEmpty:
@@ -175,7 +175,7 @@ private func fetchedNotificationSettings(network: Network) -> Signal<GlobalNotif
channelSettings = MessageNotificationSettings(enabled: enabled, displayPreviews: displayPreviews, sound: PeerMessageSound(apiSound: sound))
}
return GlobalNotificationSettingsSet(privateChats: userSettings, groupChats: chatsSettings, channels: channelSettings, contactsJoined: contactsJoined == .boolTrue)
return GlobalNotificationSettingsSet(privateChats: userSettings, groupChats: chatsSettings, channels: channelSettings, contactsJoined: contactsJoinedMuted == .boolFalse)
}
}
@@ -202,7 +202,7 @@ private func pushedNotificationSettings(network: Network, settings: GlobalNotifi
let pushedChats = network.request(Api.functions.account.updateNotifySettings(peer: Api.InputNotifyPeer.inputNotifyChats, settings: apiInputPeerNotifySettings(settings.groupChats)))
let pushedUsers = network.request(Api.functions.account.updateNotifySettings(peer: Api.InputNotifyPeer.inputNotifyUsers, settings: apiInputPeerNotifySettings(settings.privateChats)))
let pushedChannels = network.request(Api.functions.account.updateNotifySettings(peer: Api.InputNotifyPeer.inputNotifyBroadcasts, settings: apiInputPeerNotifySettings(settings.channels)))
let pushedContactsJoined = network.request(Api.functions.account.setContactSignUpNotification(silent: settings.contactsJoined ? .boolTrue : .boolFalse))
let pushedContactsJoined = network.request(Api.functions.account.setContactSignUpNotification(silent: settings.contactsJoined ? .boolFalse : .boolTrue))
return combineLatest(pushedChats, pushedUsers, pushedChannels, pushedContactsJoined)
|> retryRequest
|> mapToSignal { _ -> Signal<Void, NoError> in return .complete() }

View File

@@ -145,9 +145,9 @@ private enum HeaderPartState {
private final class MultipartUploadManager {
let parallelParts: Int = 3
let defaultPartSize: Int
let bigTotalParts: Int?
let bigParts: Bool
var defaultPartSize: Int
var bigTotalParts: Int?
var bigParts: Bool
let queue = Queue()
let fileId: Int64
@@ -225,6 +225,20 @@ private final class MultipartUploadManager {
}
func checkState() {
if let resourceData = self.resourceData, resourceData.complete && resourceData.size != 0 {
if self.committedOffset == 0 && self.uploadedParts.isEmpty && self.uploadingParts.isEmpty {
if resourceData.size > 10 * 1024 * 1024 {
self.defaultPartSize = 512 * 1024
self.bigTotalParts = (resourceData.size / self.defaultPartSize) + (resourceData.size % self.defaultPartSize == 0 ? 0 : 1)
self.bigParts = true
} else {
self.bigParts = false
self.defaultPartSize = 16 * 1024
self.bigTotalParts = nil
}
}
}
var updatedCommittedOffset = false
for offset in self.uploadedParts.keys.sorted() {
if offset == self.committedOffset {