[WIP] Chat Import

This commit is contained in:
Ali
2021-01-22 21:59:03 +04:00
parent 00cea76464
commit 04513a7624
7 changed files with 189 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ import RadialStatusNode
import AnimatedStickerNode
import AppBundle
import ZIPFoundation
import MimeTypes
public final class ChatImportActivityScreen: ViewController {
private final class Node: ViewControllerTracingNode {
@@ -191,7 +192,7 @@ public final class ChatImportActivityScreen: ViewController {
if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .immediate)
self.radialStatus.transitionToState(.progress(color: self.presentationData.theme.list.itemAccentColor, lineWidth: 6.0, value: max(0.09, self.totalProgress), cancelEnabled: false), animated: animated, synchronous: true, completion: {})
self.radialStatus.transitionToState(.progress(color: self.presentationData.theme.list.itemAccentColor, lineWidth: 6.0, value: max(0.02, self.totalProgress), cancelEnabled: false), animated: animated, synchronous: true, completion: {})
if isDone {
self.radialCheck.transitionToState(.progress(color: .clear, lineWidth: 6.0, value: self.totalProgress, cancelEnabled: false), animated: false, synchronous: true, completion: {})
self.radialCheck.transitionToState(.check(self.presentationData.theme.list.itemAccentColor), animated: animated, synchronous: true, completion: {})
@@ -362,7 +363,15 @@ public final class ChatImportActivityScreen: ViewController {
}
let uploadedMedia = unpackedFile
|> mapToSignal { tempFile -> Signal<(String, Float), ImportError> in
return ChatHistoryImport.uploadMedia(account: context.account, session: session, file: tempFile, fileName: fileName, type: mediaType)
var mimeTypeValue = "application/binary"
let fileExtension = (tempFile.path as NSString).pathExtension
if !fileExtension.isEmpty {
if let value = TGMimeTypeMap.mimeType(forExtension: fileExtension.lowercased()) {
mimeTypeValue = value
}
}
return ChatHistoryImport.uploadMedia(account: context.account, session: session, file: tempFile, fileName: fileName, mimeType: mimeTypeValue, type: mediaType)
|> mapError { _ -> ImportError in
return .generic
}