mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
ea5b4632a3
@ -9082,6 +9082,9 @@ Sorry for the inconvenience.";
|
||||
"CreateGroup.PeersTitleDelimeter" = ", ";
|
||||
"CreateGroup.PeersTitleLastDelimeter" = " and ";
|
||||
|
||||
"Conversation.SendMessageErrorTooFastTitle" = "Not so fast";
|
||||
"Conversation.SendMessageErrorTooFast" = "You are sending messages too fast. Please wait a bit.";
|
||||
|
||||
"PeerInfo.CancelSelectionAlertText" = "Cancel selection?";
|
||||
"PeerInfo.CancelSelectionAlertYes" = "Yes";
|
||||
"PeerInfo.CancelSelectionAlertNo" = "No";
|
||||
|
@ -360,13 +360,17 @@ final class MediaBoxFileContextV2Impl: MediaBoxFileContext {
|
||||
if complete {
|
||||
if let maxOffset = self.fileMap.ranges.ranges.reversed().first?.upperBound {
|
||||
let maxValue = max(resourceOffset + Int64(dataRange.count), Int64(maxOffset))
|
||||
self.fileMap.truncate(maxValue)
|
||||
self.fileMap.serialize(manager: self.manager, to: self.metaPath)
|
||||
if self.fileMap.truncationSize != maxValue {
|
||||
self.fileMap.truncate(maxValue)
|
||||
self.fileMap.serialize(manager: self.manager, to: self.metaPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .resourceSizeUpdated(size):
|
||||
self.fileMap.truncate(size)
|
||||
self.fileMap.serialize(manager: self.manager, to: self.metaPath)
|
||||
if self.fileMap.truncationSize != size {
|
||||
self.fileMap.truncate(size)
|
||||
self.fileMap.serialize(manager: self.manager, to: self.metaPath)
|
||||
}
|
||||
case let .progressUpdated(progress):
|
||||
let _ = progress
|
||||
case let .replaceHeader(data, range):
|
||||
|
@ -208,6 +208,7 @@ private final class FetchImpl {
|
||||
private let consumerId: Int64
|
||||
|
||||
private var knownSize: Int64?
|
||||
private var didReportKnownSize: Bool = false
|
||||
private var updatedFileReference: Data?
|
||||
|
||||
private var requiredRangesDisposable: Disposable?
|
||||
@ -307,6 +308,11 @@ private final class FetchImpl {
|
||||
|
||||
switch state {
|
||||
case let .fetching(state):
|
||||
if let knownSize = self.knownSize, !self.didReportKnownSize {
|
||||
self.didReportKnownSize = true
|
||||
self.onNext(.resourceSizeUpdated(knownSize))
|
||||
}
|
||||
|
||||
var filteredRequiredRanges: [RangeSet<Int64>] = []
|
||||
for _ in 0 ..< 3 {
|
||||
filteredRequiredRanges.append(RangeSet<Int64>())
|
||||
@ -349,8 +355,32 @@ private final class FetchImpl {
|
||||
}*/
|
||||
|
||||
if state.pendingParts.count < state.maxPendingParts {
|
||||
//let debugRanges = filteredRequiredRanges.ranges.map { "\($0.lowerBound)..<\($0.upperBound)" }
|
||||
//Logger.shared.log("FetchV2", "\(self.loggingIdentifier): will fetch \(debugRanges)")
|
||||
var debugRangesString = ""
|
||||
for priorityIndex in 0 ..< 3 {
|
||||
if filteredRequiredRanges[priorityIndex].isEmpty {
|
||||
continue
|
||||
}
|
||||
|
||||
if !debugRangesString.isEmpty {
|
||||
debugRangesString.append(", ")
|
||||
}
|
||||
debugRangesString.append("priority: \(priorityIndex): [")
|
||||
|
||||
var isFirst = true
|
||||
for range in filteredRequiredRanges[priorityIndex].ranges {
|
||||
if isFirst {
|
||||
isFirst = false
|
||||
} else {
|
||||
debugRangesString.append(", ")
|
||||
}
|
||||
debugRangesString.append("\(range.lowerBound)..<\(range.upperBound)")
|
||||
}
|
||||
debugRangesString.append("]")
|
||||
}
|
||||
|
||||
if !debugRangesString.isEmpty {
|
||||
Logger.shared.log("FetchV2", "\(self.loggingIdentifier): will fetch \(debugRangesString)")
|
||||
}
|
||||
|
||||
while state.pendingParts.count < state.maxPendingParts {
|
||||
var found = false
|
||||
|
@ -57,11 +57,14 @@ public enum PendingMessageFailureReason {
|
||||
case slowmodeActive
|
||||
case tooMuchScheduled
|
||||
case voiceMessagesForbidden
|
||||
case sendingTooFast
|
||||
}
|
||||
|
||||
private func reasonForError(_ error: String) -> PendingMessageFailureReason? {
|
||||
if error.hasPrefix("PEER_FLOOD") {
|
||||
return .flood
|
||||
} else if error.hasPrefix("SENDING_TOO_FAST") {
|
||||
return .sendingTooFast
|
||||
} else if error.hasPrefix("USER_BANNED_IN_CHANNEL") {
|
||||
return .publicBan
|
||||
} else if error.hasPrefix("CHAT_SEND_") && error.hasSuffix("_FORBIDDEN") {
|
||||
|
@ -10555,11 +10555,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|> deliverOnMainQueue).start(next: { [weak self] reason in
|
||||
if let strongSelf = self, strongSelf.currentFailedMessagesAlertController == nil {
|
||||
let text: String
|
||||
var title: String?
|
||||
let moreInfo: Bool
|
||||
switch reason {
|
||||
case .flood:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorFlood
|
||||
moreInfo = true
|
||||
case .sendingTooFast:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFast
|
||||
title = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFastTitle
|
||||
moreInfo = false
|
||||
case .publicBan:
|
||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorGroupRestricted
|
||||
moreInfo = true
|
||||
@ -10584,7 +10589,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
} else {
|
||||
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
||||
}
|
||||
let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: nil, text: text, actions: actions)
|
||||
let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: title, text: text, actions: actions)
|
||||
strongSelf.currentFailedMessagesAlertController = controller
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user