mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
a3b8870065
@ -508,8 +508,13 @@ public final class ChatImportActivityScreen: ViewController {
|
||||
}
|
||||
|
||||
return ChatHistoryImport.uploadMedia(account: context.account, session: session, file: tempFile, fileName: fileName, mimeType: mimeTypeValue, type: mediaType)
|
||||
|> mapError { _ -> ImportError in
|
||||
return .generic
|
||||
|> mapError { error -> ImportError in
|
||||
switch error {
|
||||
case .chatAdminRequired:
|
||||
return .chatAdminRequired
|
||||
case .generic:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> map { progress -> (String, Float) in
|
||||
return (fileName, progress)
|
||||
|
@ -100,6 +100,7 @@ public enum ChatHistoryImport {
|
||||
|
||||
public enum UploadMediaError {
|
||||
case generic
|
||||
case chatAdminRequired
|
||||
}
|
||||
|
||||
public static func uploadMedia(account: Account, session: Session, file: TempBoxFile, fileName: String, mimeType: String, type: MediaType) -> Signal<Float, UploadMediaError> {
|
||||
@ -136,8 +137,13 @@ public enum ChatHistoryImport {
|
||||
return .fail(.generic)
|
||||
}
|
||||
return account.network.request(Api.functions.messages.uploadImportedMedia(peer: session.inputPeer, importId: session.id, fileName: fileName, media: inputMedia))
|
||||
|> mapError { _ -> UploadMediaError in
|
||||
return .generic
|
||||
|> mapError { error -> UploadMediaError in
|
||||
switch error.errorDescription {
|
||||
case "CHAT_ADMIN_REQUIRED":
|
||||
return .chatAdminRequired
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Float, UploadMediaError> in
|
||||
return .single(1.0)
|
||||
|
@ -56,14 +56,14 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([
|
||||
var isFile = false
|
||||
inner: for media in message.media {
|
||||
if let _ = media as? TelegramMediaImage {
|
||||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported) {
|
||||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported), message.text.isEmpty {
|
||||
messageWithCaptionToAdd = (message, itemAttributes)
|
||||
}
|
||||
result.append((message, ChatMessageMediaBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .media, neighborSpacing: .default)))
|
||||
} else if let file = media as? TelegramMediaFile {
|
||||
let isVideo = file.isVideo || (file.isAnimated && file.dimensions != nil)
|
||||
if isVideo {
|
||||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported) {
|
||||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported), message.text.isEmpty {
|
||||
messageWithCaptionToAdd = (message, itemAttributes)
|
||||
}
|
||||
result.append((message, ChatMessageMediaBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .media, neighborSpacing: .default)))
|
||||
|
@ -542,7 +542,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
||||
} else if let statusFrameValue = statusFrame {
|
||||
if progressFrame.intersects(statusFrameValue) {
|
||||
fittedLayoutSize.height += 10.0
|
||||
statusFrame = statusFrameValue.offsetBy(dx: 0.0, dy: 15.0)
|
||||
statusFrame = statusFrameValue.offsetBy(dx: 0.0, dy: 10.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ public class ShareRootControllerImpl {
|
||||
attemptSelectionImpl = { peer in
|
||||
var errorText: String?
|
||||
if let channel = peer as? TelegramChannel {
|
||||
if channel.hasPermission(.changeInfo) {
|
||||
if channel.hasPermission(.changeInfo), (channel.flags.contains(.isCreator) || channel.adminRights != nil) {
|
||||
} else {
|
||||
errorText = "You need to be an admin of the group to import messages into it."
|
||||
}
|
||||
@ -771,7 +771,7 @@ public class ShareRootControllerImpl {
|
||||
|
||||
var errorText: String?
|
||||
if let channel = peer as? TelegramChannel {
|
||||
if channel.hasPermission(.changeInfo) {
|
||||
if channel.hasPermission(.changeInfo), (channel.flags.contains(.isCreator) || channel.adminRights != nil) {
|
||||
} else {
|
||||
errorText = "You need to be an admin of the group to import messages into it."
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user