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

This commit is contained in:
Ilya Laktyushin
2023-06-07 14:48:36 +04:00
63 changed files with 900 additions and 326 deletions

View File

@@ -297,7 +297,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
case let .asset(asset):
return .asset(asset)
case let .draft(draft):
return .draft(draft)
return .draft(draft, nil)
}
}
@@ -334,7 +334,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
} else {
return nil
}
}, completion: { [weak self] mediaResult, privacy, commit in
}, completion: { [weak self] randomId, mediaResult, privacy, commit in
guard let self else {
dismissCameraImpl?()
commit({})
@@ -347,15 +347,18 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
case let .image(image, dimensions, caption):
if let imageData = compressImageToJPEG(image, quality: 0.6) {
switch privacy {
case let .story(storyPrivacy, pin):
case let .story(storyPrivacy, period, pin):
chatListController.updateStoryUploadProgress(0.0)
let _ = (self.context.engine.messages.uploadStory(media: .image(dimensions: dimensions, data: imageData), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy)
let _ = (self.context.engine.messages.uploadStory(media: .image(dimensions: dimensions, data: imageData), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy, period: period, randomId: randomId)
|> deliverOnMainQueue).start(next: { [weak chatListController] result in
if let chatListController {
switch result {
case let .progress(progress):
chatListController.updateStoryUploadProgress(progress)
case .completed:
case let .completed(id):
if let id {
moveStorySource(engine: context.engine, from: randomId, to: Int64(id))
}
Queue.mainQueue().after(0.2) {
chatListController.updateStoryUploadProgress(nil)
}
@@ -363,9 +366,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
})
Queue.mainQueue().justDispatch {
commit({ [weak chatListController] in
chatListController?.animateStoryUploadRipple()
})
commit({})
}
case let .message(peerIds, timeout):
var randomId: Int64 = 0
@@ -382,7 +383,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
let media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: imageFlags)
if let timeout, timeout > 0 && timeout <= 60 {
attributes.append(AutoremoveTimeoutMessageAttribute(timeout: timeout, countdownBeginTime: nil))
attributes.append(AutoremoveTimeoutMessageAttribute(timeout: Int32(timeout), countdownBeginTime: nil))
}
let text = trimChatInputText(convertMarkdownToAttributes(caption ?? NSAttributedString()))
@@ -435,15 +436,18 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
case let .asset(localIdentifier):
resource = VideoLibraryMediaResource(localIdentifier: localIdentifier, conversion: .compress(adjustments))
}
if case let .story(storyPrivacy, pin) = privacy {
if case let .story(storyPrivacy, period, pin) = privacy {
chatListController.updateStoryUploadProgress(0.0)
let _ = (self.context.engine.messages.uploadStory(media: .video(dimensions: dimensions, duration: Int(duration), resource: resource), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy)
let _ = (self.context.engine.messages.uploadStory(media: .video(dimensions: dimensions, duration: duration, resource: resource), text: caption?.string ?? "", entities: [], pin: pin, privacy: storyPrivacy, period: period, randomId: randomId)
|> deliverOnMainQueue).start(next: { [weak chatListController] result in
if let chatListController {
switch result {
case let .progress(progress):
chatListController.updateStoryUploadProgress(progress)
case .completed:
case let .completed(id):
if let id {
moveStorySource(engine: context.engine, from: randomId, to: Int64(id))
}
Queue.mainQueue().after(0.2) {
chatListController.updateStoryUploadProgress(nil)
}
@@ -451,9 +455,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
})
Queue.mainQueue().justDispatch {
commit({ [weak chatListController] in
chatListController?.animateStoryUploadRipple()
})
commit({})
}
} else {
commit({})