mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix video transcription text update
This commit is contained in:
parent
fc2a32678b
commit
d9fb54b67f
@ -60,15 +60,20 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
let _ = item.controllerInteraction.requestMessageUpdate(item.message.id)
|
||||
}
|
||||
}
|
||||
self.interactiveVideoNode.updateTranscribeExpanded = { [weak self] state, text in
|
||||
self.interactiveVideoNode.updateTranscriptionExpanded = { [weak self] state in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
strongSelf.audioTranscriptionState = state
|
||||
strongSelf.interactiveFileNode.audioTranscriptionState = state
|
||||
let _ = item.controllerInteraction.requestMessageUpdate(item.message.id)
|
||||
}
|
||||
}
|
||||
self.interactiveVideoNode.updateTranscriptionText = { [weak self] text in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
strongSelf.interactiveFileNode.forcedAudioTranscriptionText = text
|
||||
let _ = item.controllerInteraction.requestMessageUpdate(item.message.id)
|
||||
}
|
||||
}
|
||||
self.interactiveFileNode.updateTranscribeExpanded = { [weak self] state in
|
||||
self.interactiveFileNode.updateTranscriptionExpanded = { [weak self] state in
|
||||
if let strongSelf = self, let item = strongSelf.item {
|
||||
strongSelf.audioTranscriptionState = state
|
||||
strongSelf.interactiveVideoNode.audioTranscriptionState = state
|
||||
|
@ -32,7 +32,7 @@ private struct FetchControls {
|
||||
let cancel: () -> Void
|
||||
}
|
||||
|
||||
enum TranscribedText {
|
||||
enum TranscribedText: Equatable {
|
||||
case success(text: String, isPending: Bool)
|
||||
case error(AudioTranscriptionMessageAttribute.TranscriptionError)
|
||||
}
|
||||
@ -199,7 +199,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
||||
var requestUpdateLayout: (Bool) -> Void = { _ in }
|
||||
var displayImportedTooltip: (ASDisplayNode) -> Void = { _ in }
|
||||
|
||||
var updateTranscribeExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState) -> Void)?
|
||||
var updateTranscriptionExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState) -> Void)?
|
||||
|
||||
private var context: AccountContext?
|
||||
private var message: Message?
|
||||
@ -447,7 +447,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode {
|
||||
self.audioTranscriptionState = .collapsed
|
||||
self.isWaitingForCollapse = true
|
||||
self.requestUpdateLayout(true)
|
||||
self.updateTranscribeExpanded?(self.audioTranscriptionState)
|
||||
self.updateTranscriptionExpanded?(self.audioTranscriptionState)
|
||||
case .collapsed:
|
||||
self.audioTranscriptionState = .inProgress
|
||||
self.requestUpdateLayout(true)
|
||||
|
@ -112,6 +112,9 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
|
||||
var shouldOpen: () -> Bool = { return true }
|
||||
|
||||
var updateTranscriptionExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState) -> Void)?
|
||||
var updateTranscriptionText: ((TranscribedText?) -> Void)?
|
||||
|
||||
var audioTranscriptionState: AudioTranscriptionButtonComponent.TranscriptionState = .collapsed
|
||||
var audioTranscriptionText: TranscribedText?
|
||||
private var transcribeDisposable: Disposable?
|
||||
@ -199,6 +202,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
let makeDateAndStatusLayout = self.dateAndStatusNode.asyncLayout()
|
||||
|
||||
let audioTranscriptionState = self.audioTranscriptionState
|
||||
let audioTranscriptionText = self.audioTranscriptionText
|
||||
|
||||
return { item, width, displaySize, maximumDisplaySize, scaleProgress, statusDisplayType, automaticDownload in
|
||||
var secretVideoPlaceholderBackgroundImage: UIImage?
|
||||
@ -399,6 +403,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
break
|
||||
}
|
||||
|
||||
var updatedTranscriptionText: TranscribedText?
|
||||
if audioTranscriptionText != transcribedText {
|
||||
updatedTranscriptionText = transcribedText
|
||||
}
|
||||
|
||||
let effectiveAudioTranscriptionState = updatedAudioTranscriptionState ?? audioTranscriptionState
|
||||
|
||||
return (result, { [weak self] layoutData, animation in
|
||||
@ -410,10 +419,13 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
|
||||
if let updatedAudioTranscriptionState = updatedAudioTranscriptionState {
|
||||
strongSelf.audioTranscriptionState = updatedAudioTranscriptionState
|
||||
strongSelf.audioTranscriptionText = transcribedText
|
||||
strongSelf.updateTranscribeExpanded?(updatedAudioTranscriptionState, transcribedText)
|
||||
strongSelf.updateTranscriptionExpanded?(strongSelf.audioTranscriptionState)
|
||||
}
|
||||
|
||||
if let updatedTranscriptionText = updatedTranscriptionText {
|
||||
strongSelf.audioTranscriptionText = updatedTranscriptionText
|
||||
strongSelf.updateTranscriptionText?(strongSelf.audioTranscriptionText)
|
||||
}
|
||||
|
||||
if let updatedInfoBackgroundImage = updatedInfoBackgroundImage {
|
||||
strongSelf.infoBackgroundNode.image = updatedInfoBackgroundImage
|
||||
}
|
||||
@ -1151,7 +1163,6 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
var updateTranscribeExpanded: ((AudioTranscriptionButtonComponent.TranscriptionState, TranscribedText?) -> Void)?
|
||||
private func transcribe() {
|
||||
guard let context = self.item?.context, let message = self.item?.message, self.statusNode == nil else {
|
||||
return
|
||||
@ -1205,7 +1216,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
self.updateTranscribeExpanded?(self.audioTranscriptionState, self.audioTranscriptionText)
|
||||
self.updateTranscriptionExpanded?(self.audioTranscriptionState)
|
||||
}
|
||||
|
||||
func animateTo(_ node: ChatMessageInteractiveFileNode, animator: ControlledTransitionAnimator) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user