Various fixes

This commit is contained in:
Ilya Laktyushin 2023-08-31 18:30:33 +04:00
parent 0c2266aa73
commit a690eb8033
6 changed files with 48 additions and 8 deletions

View File

@ -9870,3 +9870,8 @@ Sorry for the inconvenience.";
"Story.Privacy.KeepOnChannelPageInfo" = "Keep this story on channel profile even after it expires in %@."; "Story.Privacy.KeepOnChannelPageInfo" = "Keep this story on channel profile even after it expires in %@.";
"Story.Editor.TooltipPremiumReaction" = "Subscribe to [Telegram Premium]() to use this reaction."; "Story.Editor.TooltipPremiumReaction" = "Subscribe to [Telegram Premium]() to use this reaction.";
"Story.Privacy.TooltipStoryArchivedChannel" = "Users will see this story on the channel page even after it expires.";
"Story.Editor.TooltipMutedWithAudio" = "Original audio will be removed";
"Story.Editor.TooltipUnmutedWithAudio" = "Original audio will be preserved";

View File

@ -139,6 +139,7 @@ public final class SecretMediaPreviewController: ViewController {
private var messageView: MessageView? private var messageView: MessageView?
private var currentNodeMessageId: MessageId? private var currentNodeMessageId: MessageId?
private var currentNodeMessageIsVideo = false private var currentNodeMessageIsVideo = false
private var currentNodeMessageIsViewOnce = false
private var tempFile: TempBoxFile? private var tempFile: TempBoxFile?
private let _hiddenMedia = Promise<(MessageId, Media)?>(nil) private let _hiddenMedia = Promise<(MessageId, Media)?>(nil)
@ -263,6 +264,8 @@ public final class SecretMediaPreviewController: ViewController {
} }
if let attribute = message.autoclearAttribute { if let attribute = message.autoclearAttribute {
strongSelf.currentNodeMessageIsViewOnce = attribute.timeout == viewOnceTimeout
if let countdownBeginTime = attribute.countdownBeginTime { if let countdownBeginTime = attribute.countdownBeginTime {
if let videoDuration = videoDuration { if let videoDuration = videoDuration {
beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, videoDuration) beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, videoDuration)
@ -271,6 +274,8 @@ public final class SecretMediaPreviewController: ViewController {
} }
} }
} else if let attribute = message.autoremoveAttribute { } else if let attribute = message.autoremoveAttribute {
strongSelf.currentNodeMessageIsViewOnce = attribute.timeout == viewOnceTimeout
if let countdownBeginTime = attribute.countdownBeginTime { if let countdownBeginTime = attribute.countdownBeginTime {
if let videoDuration = videoDuration { if let videoDuration = videoDuration {
beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, videoDuration) beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, videoDuration)
@ -478,7 +483,7 @@ public final class SecretMediaPreviewController: ViewController {
if !self.didSetReady { if !self.didSetReady {
self._ready.set(.single(true)) self._ready.set(.single(true))
} }
if !self.currentNodeMessageIsVideo { if !(self.currentNodeMessageIsVideo && !self.currentNodeMessageIsViewOnce) {
self.dismiss() self.dismiss()
} }
} }

View File

@ -56,7 +56,11 @@ public class AutoclearTimeoutMessageAttribute: MessageAttribute {
self.countdownBeginTime = countdownBeginTime self.countdownBeginTime = countdownBeginTime
if let countdownBeginTime = countdownBeginTime { if let countdownBeginTime = countdownBeginTime {
self.automaticTimestampBasedAttribute = (1, countdownBeginTime + timeout) if self.timeout == viewOnceTimeout {
self.automaticTimestampBasedAttribute = (1, countdownBeginTime)
} else {
self.automaticTimestampBasedAttribute = (1, countdownBeginTime + timeout)
}
} else { } else {
self.automaticTimestampBasedAttribute = nil self.automaticTimestampBasedAttribute = nil
} }
@ -67,7 +71,11 @@ public class AutoclearTimeoutMessageAttribute: MessageAttribute {
self.countdownBeginTime = decoder.decodeOptionalInt32ForKey("c") self.countdownBeginTime = decoder.decodeOptionalInt32ForKey("c")
if let countdownBeginTime = self.countdownBeginTime { if let countdownBeginTime = self.countdownBeginTime {
self.automaticTimestampBasedAttribute = (1, countdownBeginTime + self.timeout) if self.timeout == viewOnceTimeout {
self.automaticTimestampBasedAttribute = (1, countdownBeginTime)
} else {
self.automaticTimestampBasedAttribute = (1, countdownBeginTime + self.timeout)
}
} else { } else {
self.automaticTimestampBasedAttribute = nil self.automaticTimestampBasedAttribute = nil
} }

View File

@ -83,7 +83,7 @@ func _internal_markMessageContentAsConsumedInteractively(postbox: Postbox, messa
} else if let attribute = updatedAttributes[i] as? AutoclearTimeoutMessageAttribute { } else if let attribute = updatedAttributes[i] as? AutoclearTimeoutMessageAttribute {
if attribute.countdownBeginTime == nil || attribute.countdownBeginTime == 0 { if attribute.countdownBeginTime == nil || attribute.countdownBeginTime == 0 {
var timeout = attribute.timeout var timeout = attribute.timeout
if let duration = message.secretMediaDuration { if let duration = message.secretMediaDuration, timeout != viewOnceTimeout {
timeout = max(timeout, Int32(duration)) timeout = max(timeout, Int32(duration))
} }
updatedAttributes[i] = AutoclearTimeoutMessageAttribute(timeout: timeout, countdownBeginTime: timestamp) updatedAttributes[i] = AutoclearTimeoutMessageAttribute(timeout: timeout, countdownBeginTime: timestamp)

View File

@ -2778,7 +2778,22 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
let absoluteFrame = sourceView.convert(sourceView.bounds, to: nil).offsetBy(dx: -parentFrame.minX, dy: 0.0) let absoluteFrame = sourceView.convert(sourceView.bounds, to: nil).offsetBy(dx: -parentFrame.minX, dy: 0.0)
let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.maxY + 3.0), size: CGSize()) let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.maxY + 3.0), size: CGSize())
let tooltipController = TooltipScreen(account: self.context.account, sharedContext: self.context.sharedContext, text: .plain(text: isMuted ? self.presentationData.strings.Story_Editor_TooltipMuted : self.presentationData.strings.Story_Editor_TooltipUnmuted), location: .point(location, .top), displayDuration: .default, inset: 16.0, shouldDismissOnTouch: { _, _ in let text: String
if let _ = self.mediaEditor?.values.audioTrack {
if isMuted {
text = self.presentationData.strings.Story_Editor_TooltipMutedWithAudio
} else {
text = self.presentationData.strings.Story_Editor_TooltipUnmutedWithAudio
}
} else {
if isMuted {
text = self.presentationData.strings.Story_Editor_TooltipMuted
} else {
text = self.presentationData.strings.Story_Editor_TooltipUnmuted
}
}
let tooltipController = TooltipScreen(account: self.context.account, sharedContext: self.context.sharedContext, text: .plain(text: text), location: .point(location, .top), displayDuration: .default, inset: 16.0, shouldDismissOnTouch: { _, _ in
return .ignore return .ignore
}) })
self.muteTooltip = tooltipController self.muteTooltip = tooltipController

View File

@ -345,6 +345,8 @@ final class ShareWithPeersScreenComponent: Component {
private var searchStateContext: ShareWithPeersScreen.StateContext? private var searchStateContext: ShareWithPeersScreen.StateContext?
private var searchStateDisposable: Disposable? private var searchStateDisposable: Disposable?
private let hapticFeedback = HapticFeedback()
private var effectiveStateValue: ShareWithPeersScreen.State? { private var effectiveStateValue: ShareWithPeersScreen.State? {
return self.searchStateContext?.stateValue ?? self.defaultStateValue return self.searchStateContext?.stateValue ?? self.defaultStateValue
} }
@ -549,7 +551,11 @@ final class ShareWithPeersScreenComponent: Component {
case .pin: case .pin:
if self.selectedOptions.contains(.pin) { if self.selectedOptions.contains(.pin) {
animationName = "anim_profileadd" animationName = "anim_profileadd"
text = presentationData.strings.Story_Privacy_TooltipStoryArchived if let peerId = self.sendAsPeerId, peerId.namespace != Namespaces.Peer.CloudUser {
text = presentationData.strings.Story_Privacy_TooltipStoryArchivedChannel
} else {
text = presentationData.strings.Story_Privacy_TooltipStoryArchived
}
} else { } else {
animationName = "anim_autoremove_on" animationName = "anim_autoremove_on"
text = presentationData.strings.Story_Privacy_TooltipStoryExpires text = presentationData.strings.Story_Privacy_TooltipStoryExpires
@ -996,9 +1002,9 @@ final class ShareWithPeersScreenComponent: Component {
let subtitle: String? let subtitle: String?
if case .user = peer { if case .user = peer {
subtitle = "personal account" subtitle = environment.strings.VoiceChat_PersonalAccount
} else { } else {
subtitle = "channel" subtitle = environment.strings.Channel_Status
} }
var isStories = false var isStories = false
@ -1037,6 +1043,7 @@ final class ShareWithPeersScreenComponent: Component {
if isStories { if isStories {
let _ = self.presentSendAsPeer() let _ = self.presentSendAsPeer()
} else { } else {
self.hapticFeedback.tap()
self.environment?.controller()?.dismiss() self.environment?.controller()?.dismiss()
self.component?.peerCompletion(peer.id) self.component?.peerCompletion(peer.id)
} }