From a690eb803323f809824a33a010f488dc647e8439 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 31 Aug 2023 18:30:33 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 5 +++++ .../Sources/SecretMediaPreviewController.swift | 7 ++++++- ...Core_AutoremoveTimeoutMessageAttribute.swift | 12 ++++++++++-- ...kMessageContentAsConsumedInteractively.swift | 2 +- .../Sources/MediaEditorScreen.swift | 17 ++++++++++++++++- .../Sources/ShareWithPeersScreen.swift | 13 ++++++++++--- 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 2f3ea5fe2b..150de95c72 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -9870,3 +9870,8 @@ Sorry for the inconvenience."; "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.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"; diff --git a/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift b/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift index 26a0fddda9..d0aa31a36b 100644 --- a/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift +++ b/submodules/GalleryUI/Sources/SecretMediaPreviewController.swift @@ -139,6 +139,7 @@ public final class SecretMediaPreviewController: ViewController { private var messageView: MessageView? private var currentNodeMessageId: MessageId? private var currentNodeMessageIsVideo = false + private var currentNodeMessageIsViewOnce = false private var tempFile: TempBoxFile? private let _hiddenMedia = Promise<(MessageId, Media)?>(nil) @@ -263,6 +264,8 @@ public final class SecretMediaPreviewController: ViewController { } if let attribute = message.autoclearAttribute { + strongSelf.currentNodeMessageIsViewOnce = attribute.timeout == viewOnceTimeout + if let countdownBeginTime = attribute.countdownBeginTime { if let videoDuration = videoDuration { beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, videoDuration) @@ -271,6 +274,8 @@ public final class SecretMediaPreviewController: ViewController { } } } else if let attribute = message.autoremoveAttribute { + strongSelf.currentNodeMessageIsViewOnce = attribute.timeout == viewOnceTimeout + if let countdownBeginTime = attribute.countdownBeginTime { if let videoDuration = videoDuration { beginTimeAndTimeout = (CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970, videoDuration) @@ -478,7 +483,7 @@ public final class SecretMediaPreviewController: ViewController { if !self.didSetReady { self._ready.set(.single(true)) } - if !self.currentNodeMessageIsVideo { + if !(self.currentNodeMessageIsVideo && !self.currentNodeMessageIsViewOnce) { self.dismiss() } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_AutoremoveTimeoutMessageAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_AutoremoveTimeoutMessageAttribute.swift index 2ec5399c1e..b8c99a0b3f 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_AutoremoveTimeoutMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_AutoremoveTimeoutMessageAttribute.swift @@ -56,7 +56,11 @@ public class AutoclearTimeoutMessageAttribute: MessageAttribute { self.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 { self.automaticTimestampBasedAttribute = nil } @@ -67,7 +71,11 @@ public class AutoclearTimeoutMessageAttribute: MessageAttribute { self.countdownBeginTime = decoder.decodeOptionalInt32ForKey("c") 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 { self.automaticTimestampBasedAttribute = nil } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/MarkMessageContentAsConsumedInteractively.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/MarkMessageContentAsConsumedInteractively.swift index 1916744a13..46be899ce2 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/MarkMessageContentAsConsumedInteractively.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/MarkMessageContentAsConsumedInteractively.swift @@ -83,7 +83,7 @@ func _internal_markMessageContentAsConsumedInteractively(postbox: Postbox, messa } else if let attribute = updatedAttributes[i] as? AutoclearTimeoutMessageAttribute { if attribute.countdownBeginTime == nil || attribute.countdownBeginTime == 0 { var timeout = attribute.timeout - if let duration = message.secretMediaDuration { + if let duration = message.secretMediaDuration, timeout != viewOnceTimeout { timeout = max(timeout, Int32(duration)) } updatedAttributes[i] = AutoclearTimeoutMessageAttribute(timeout: timeout, countdownBeginTime: timestamp) diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 8c88fd1dfa..baabfbea55 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -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 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 }) self.muteTooltip = tooltipController diff --git a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift index 56dbc068be..b4c2c05db2 100644 --- a/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift +++ b/submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift @@ -345,6 +345,8 @@ final class ShareWithPeersScreenComponent: Component { private var searchStateContext: ShareWithPeersScreen.StateContext? private var searchStateDisposable: Disposable? + private let hapticFeedback = HapticFeedback() + private var effectiveStateValue: ShareWithPeersScreen.State? { return self.searchStateContext?.stateValue ?? self.defaultStateValue } @@ -549,7 +551,11 @@ final class ShareWithPeersScreenComponent: Component { case .pin: if self.selectedOptions.contains(.pin) { 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 { animationName = "anim_autoremove_on" text = presentationData.strings.Story_Privacy_TooltipStoryExpires @@ -996,9 +1002,9 @@ final class ShareWithPeersScreenComponent: Component { let subtitle: String? if case .user = peer { - subtitle = "personal account" + subtitle = environment.strings.VoiceChat_PersonalAccount } else { - subtitle = "channel" + subtitle = environment.strings.Channel_Status } var isStories = false @@ -1037,6 +1043,7 @@ final class ShareWithPeersScreenComponent: Component { if isStories { let _ = self.presentSendAsPeer() } else { + self.hapticFeedback.tap() self.environment?.controller()?.dismiss() self.component?.peerCompletion(peer.id) }