diff --git a/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift b/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift index 17e946843c..1551fcf407 100644 --- a/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift +++ b/submodules/BrowserUI/Sources/BrowserAddressListComponent.swift @@ -370,7 +370,7 @@ final class BrowserAddressListComponent: Component { if let media = message.media.first(where: { $0 is TelegramMediaWebpage }) as? TelegramMediaWebpage { webPage = media } else { - webPage = TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: primaryUrl, displayUrl: "", hash: 0, type: nil, websiteName: "", title: message.text, text: "", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))) + webPage = TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: primaryUrl, displayUrl: "", hash: 0, type: nil, websiteName: "", title: message.text, text: "", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))) } itemMessage = message } else { @@ -560,7 +560,7 @@ final class BrowserAddressListComponent: Component { component: AnyComponent(BrowserAddressListItemComponent( context: component.context, theme: component.theme, - webPage: TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "https://telegram.org", displayUrl: "https://telegram.org", hash: 0, type: nil, websiteName: "Telegram", title: "Telegram Telegram", text: "Telegram", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))), + webPage: TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "https://telegram.org", displayUrl: "https://telegram.org", hash: 0, type: nil, websiteName: "Telegram", title: "Telegram Telegram", text: "Telegram", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))), message: nil, hasNext: true, insets: .zero, diff --git a/submodules/BrowserUI/Sources/BrowserReadability.swift b/submodules/BrowserUI/Sources/BrowserReadability.swift index 25b4dda6ae..4f734d98e4 100644 --- a/submodules/BrowserUI/Sources/BrowserReadability.swift +++ b/submodules/BrowserUI/Sources/BrowserReadability.swift @@ -138,6 +138,7 @@ private func parseJson(_ input: [String: Any], url: String) -> TelegramMediaWebp duration: nil, author: byline, isMediaLargeByDefault: nil, + imageIsVideoCover: false, image: nil, file: nil, story: nil, diff --git a/submodules/BrowserUI/Sources/BrowserWebContent.swift b/submodules/BrowserUI/Sources/BrowserWebContent.swift index 7ffc272b6c..4866b8d284 100644 --- a/submodules/BrowserUI/Sources/BrowserWebContent.swift +++ b/submodules/BrowserUI/Sources/BrowserWebContent.swift @@ -1023,7 +1023,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU } self.instantPage = webPage self.instantPageResources = resources - let _ = (updatedRemoteWebpage(postbox: self.context.account.postbox, network: self.context.account.network, accountPeerId: self.context.account.peerId, webPage: WebpageReference(TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: self._state.url, displayUrl: "", hash: 0, type: nil, websiteName: nil, title: nil, text: nil, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))) + let _ = (updatedRemoteWebpage(postbox: self.context.account.postbox, network: self.context.account.network, accountPeerId: self.context.account.peerId, webPage: WebpageReference(TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: self._state.url, displayUrl: "", hash: 0, type: nil, websiteName: nil, title: nil, text: nil, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))) |> deliverOnMainQueue).start(next: { [weak self] webPage in guard let self, let webPage, case let .Loaded(result) = webPage.content, let _ = result.instantPage else { return @@ -1518,6 +1518,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU duration: nil, author: nil, isMediaLargeByDefault: nil, + imageIsVideoCover: false, image: image, file: nil, story: nil, diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 7d12d87d6b..0d98af1190 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -5286,7 +5286,7 @@ public final class ChatListSearchShimmerNode: ASDisplayNode { return nil case .links: var media: [EngineMedia] = [] - media.append(.webpage(TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "https://telegram.org", displayUrl: "https://telegram.org", hash: 0, type: nil, websiteName: "Telegram", title: "Telegram Telegram", text: "Telegram", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))) + media.append(.webpage(TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "https://telegram.org", displayUrl: "https://telegram.org", hash: 0, type: nil, websiteName: "Telegram", title: "Telegram Telegram", text: "Telegram", embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil))))) let message = EngineMessage( stableId: 0, stableVersion: 0, diff --git a/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift b/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift index 2862676fbd..eae0aa5176 100644 --- a/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift +++ b/submodules/ContextUI/Sources/ContextControllerActionsStackNode.swift @@ -172,8 +172,10 @@ public final class ContextControllerActionsListActionItemNode: HighlightTracking } if highlighted { strongSelf.highlightBackgroundNode.alpha = 1.0 + strongSelf.startTimer() } else { strongSelf.highlightBackgroundNode.alpha = 0.0 + strongSelf.invalidateTimer() } } @@ -183,6 +185,25 @@ public final class ContextControllerActionsListActionItemNode: HighlightTracking deinit { self.iconDisposable?.dispose() } + + private var timer: SwiftSignalKit.Timer? + private func startTimer() { + self.invalidateTimer() + + self.timer = SwiftSignalKit.Timer(timeout: 1.0, repeat: false, completion: { [weak self] in + guard let self else { + return + } + self.invalidateTimer() + self.longPressed() + }, queue: Queue.mainQueue()) + self.timer?.start() + } + + private func invalidateTimer() { + self.timer?.invalidate() + self.timer = nil + } public override func didLoad() { super.didLoad() @@ -191,6 +212,8 @@ public final class ContextControllerActionsListActionItemNode: HighlightTracking } @objc private func pressed() { + self.invalidateTimer() + self.item.action?(ContextMenuActionItem.Action( controller: self.getController(), dismissWithResult: { [weak self] result in @@ -208,6 +231,26 @@ public final class ContextControllerActionsListActionItemNode: HighlightTracking )) } + private func longPressed() { + self.touchesCancelled(nil, with: nil) + + self.item.longPressAction?(ContextMenuActionItem.Action( + controller: self.getController(), + dismissWithResult: { [weak self] result in + guard let strongSelf = self else { + return + } + strongSelf.requestDismiss(result) + }, + updateAction: { [weak self] id, updatedAction in + guard let strongSelf = self else { + return + } + strongSelf.requestUpdateAction(id, updatedAction) + } + )) + } + public func canBeHighlighted() -> Bool { return self.item.action != nil } diff --git a/submodules/InstantPageUI/Sources/InstantPageLayout.swift b/submodules/InstantPageUI/Sources/InstantPageLayout.swift index 27d11e6dd0..92c72bc266 100644 --- a/submodules/InstantPageUI/Sources/InstantPageLayout.swift +++ b/submodules/InstantPageUI/Sources/InstantPageLayout.swift @@ -632,7 +632,7 @@ public func layoutInstantPageBlock(webpage: TelegramMediaWebpage, userLocation: let frame = CGRect(origin: CGPoint(x: floor((boundingWidth - size.width) / 2.0), y: 0.0), size: size) let item: InstantPageItem if let url = url, let coverId = coverId, case let .image(image) = media[coverId] { - let loadedContent = TelegramMediaWebpageLoadedContent(url: url, displayUrl: url, hash: 0, type: "video", websiteName: nil, title: nil, text: nil, embedUrl: url, embedType: "video", embedSize: PixelDimensions(size), duration: nil, author: nil, isMediaLargeByDefault: nil, image: image, file: nil, story: nil, attributes: [], instantPage: nil) + let loadedContent = TelegramMediaWebpageLoadedContent(url: url, displayUrl: url, hash: 0, type: "video", websiteName: nil, title: nil, text: nil, embedUrl: url, embedType: "video", embedSize: PixelDimensions(size), duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: image, file: nil, story: nil, attributes: [], instantPage: nil) let content = TelegramMediaWebpageContent.Loaded(loadedContent) item = InstantPageImageItem(frame: frame, webPage: webpage, media: InstantPageMedia(index: embedIndex, media: .webpage(TelegramMediaWebpage(webpageId: EngineMedia.Id(namespace: Namespaces.Media.LocalWebpage, id: -1), content: content)), url: nil, caption: nil, credit: nil), attributes: [], interactive: true, roundCorners: false, fit: false) diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaEditingContext.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaEditingContext.h index 4a34949e3c..971042d722 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaEditingContext.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaEditingContext.h @@ -63,9 +63,12 @@ - (void)setFullSizeImage:(UIImage *)image forItem:(id)item; - (SSignal *)coverImageSignalForItem:(NSObject *)item; -- (void)setCoverImage:(UIImage *)image forItem:(id)item; +- (void)setCoverImage:(UIImage *)image position:(NSNumber *)position forItem:(id)item; - (UIImage *)coverImageForItem:(NSObject *)item; +- (NSNumber *)coverPositionForItem:(NSObject *)item; +- (void)setCoverImage:(UIImage *)image position:(NSNumber *)position forItem:(id)item; + - (void)setTemporaryRep:(id)rep forItem:(id)item; - (SSignal *)fullSizeImageUrlForItem:(id)item; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerGalleryVideoItemView.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerGalleryVideoItemView.h index b6925cb9bd..c696c3a423 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerGalleryVideoItemView.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerGalleryVideoItemView.h @@ -34,6 +34,7 @@ - (void)prepareForCoverEditing; - (void)returnFromCoverEditing; +- (NSTimeInterval)currentPosition; - (UIImage *)screenImage; - (UIImage *)transitionImage; - (CGRect)editorTransitionViewRect; diff --git a/submodules/LegacyComponents/Sources/TGMediaEditingContext.m b/submodules/LegacyComponents/Sources/TGMediaEditingContext.m index 42b7764772..e1f9cfab72 100644 --- a/submodules/LegacyComponents/Sources/TGMediaEditingContext.m +++ b/submodules/LegacyComponents/Sources/TGMediaEditingContext.m @@ -107,6 +107,7 @@ TGMemoryImageCache *_originalThumbnailImageCache; TGMemoryImageCache *_coverImageCache; + NSMutableDictionary *_coverPositions; TGModernCache *_diskCache; NSURL *_fullSizeResultsUrl; @@ -171,6 +172,7 @@ _coverImageCache = [[TGMemoryImageCache alloc] initWithSoftMemoryLimit:[[self class] thumbnailImageSoftMemoryLimit] * 10 hardMemoryLimit:[[self class] thumbnailImageHardMemoryLimit] * 10]; + _coverPositions = [[NSMutableDictionary alloc] init]; NSString *diskCachePath = [[[LegacyComponentsGlobals provider] dataStoragePath] stringByAppendingPathComponent:[[self class] diskCachePath]]; _diskCache = [[TGModernCache alloc] initWithPath:diskCachePath size:[[self class] diskMemoryLimit]]; @@ -945,7 +947,14 @@ return [_coverImageCache imageForKey:itemId attributes:NULL]; } -- (void)setCoverImage:(UIImage *)image forItem:(id)item +- (NSNumber *)coverPositionForItem:(NSObject *)item { + NSString *itemId = [TGMediaEditingContext _coverImageUriForItemId:item.uniqueIdentifier]; + if (itemId == nil) + return nil; + return _coverPositions[itemId]; +} + +- (void)setCoverImage:(UIImage *)image position:(NSNumber *)position forItem:(id)item { NSString *itemId = [TGMediaEditingContext _coverImageUriForItemId:item.uniqueIdentifier]; if (itemId == nil) @@ -953,6 +962,7 @@ [_coverImageCache setImage:image forKey:itemId attributes:NULL]; _coverImagePipe.sink([TGMediaImageUpdate imageUpdateWithItem:item representation:image]); + [_coverPositions setObject:position forKey:itemId]; } - (void)setFullSizeImage:(UIImage *)image forItem:(id)item diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m index b3896649c7..288e2a4077 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m @@ -931,7 +931,7 @@ TGModernGalleryItemView *currentItemView = _currentItemView; if ([currentItemView isKindOfClass:[TGMediaPickerGalleryVideoItemView class]]) { id editableMediaItem = [galleryEditableItem editableMediaItem]; - [_editingContext setCoverImage:[(TGMediaPickerGalleryVideoItemView *)currentItemView screenImage] forItem:editableMediaItem]; + [_editingContext setCoverImage:[(TGMediaPickerGalleryVideoItemView *)currentItemView screenImage] position:@([(TGMediaPickerGalleryVideoItemView *)currentItemView currentPosition]) forItem:editableMediaItem]; } TGDispatchAfter(0.01, dispatch_get_main_queue(), ^{ @@ -956,7 +956,7 @@ __strong TGMediaPickerGalleryInterfaceView *strongSelf = weakSelf; if (strongSelf == nil) return; - [strongSelf->_editingContext setCoverImage:cover forItem:editableMediaItem]; + [strongSelf->_editingContext setCoverImage:cover position:nil forItem:editableMediaItem]; [strongSelf coverEditorTransitionOut]; }); } diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m index 6cb1da5c02..581a462475 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m @@ -768,6 +768,13 @@ _isCoverEditing = true; [self setPlayButtonHidden:true animated:true]; [self stop]; + + NSNumber *savedPosition = [self.item.editingContext coverPositionForItem:self.item.editableMediaItem]; + if (savedPosition != nil) { + [self _seekToPosition:savedPosition.doubleValue manual:false]; + [_scrubberView setValue:savedPosition.doubleValue resetPosition:true]; + [_coverScrubberView setValue:savedPosition.doubleValue resetPosition:true]; + } } - (void)returnFromCoverEditing @@ -941,6 +948,10 @@ } } +- (NSTimeInterval)currentPosition { + return _coverScrubberView.value; +} + - (UIImage *)screenImage { if (_videoView != nil) diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebpage.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebpage.swift index 3fc7a03776..9bb922487e 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebpage.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebpage.swift @@ -74,8 +74,9 @@ func telegramMediaWebpageFromApiWebpage(_ webpage: Api.WebPage) -> TelegramMedia } let isMediaLargeByDefault = (flags & (1 << 13)) != 0 + let imageIsVideoCover = (flags & (1 << 14)) != 0 - return TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.CloudWebpage, id: id), content: .Loaded(TelegramMediaWebpageLoadedContent(url: url, displayUrl: displayUrl, hash: hash, type: type, websiteName: siteName, title: title, text: description, embedUrl: embedUrl, embedType: embedType, embedSize: embedSize, duration: webpageDuration, author: author, isMediaLargeByDefault: isMediaLargeByDefault, image: image, file: file, story: story, attributes: webpageAttributes, instantPage: instantPage))) + return TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.CloudWebpage, id: id), content: .Loaded(TelegramMediaWebpageLoadedContent(url: url, displayUrl: displayUrl, hash: hash, type: type, websiteName: siteName, title: title, text: description, embedUrl: embedUrl, embedType: embedType, embedSize: embedSize, duration: webpageDuration, author: author, isMediaLargeByDefault: isMediaLargeByDefault, imageIsVideoCover: imageIsVideoCover, image: image, file: file, story: story, attributes: webpageAttributes, instantPage: instantPage))) case .webPageEmpty: return nil } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebpage.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebpage.swift index 7d792980d9..7437b40637 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebpage.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebpage.swift @@ -171,6 +171,7 @@ public final class TelegramMediaWebpageLoadedContent: PostboxCoding, Equatable { public let duration: Int? public let author: String? public let isMediaLargeByDefault: Bool? + public let imageIsVideoCover: Bool public let image: TelegramMediaImage? public let file: TelegramMediaFile? @@ -192,6 +193,7 @@ public final class TelegramMediaWebpageLoadedContent: PostboxCoding, Equatable { duration: Int?, author: String?, isMediaLargeByDefault: Bool?, + imageIsVideoCover: Bool, image: TelegramMediaImage?, file: TelegramMediaFile?, story: TelegramMediaStory?, @@ -211,6 +213,7 @@ public final class TelegramMediaWebpageLoadedContent: PostboxCoding, Equatable { self.duration = duration self.author = author self.isMediaLargeByDefault = isMediaLargeByDefault + self.imageIsVideoCover = imageIsVideoCover self.image = image self.file = file self.story = story @@ -240,6 +243,7 @@ public final class TelegramMediaWebpageLoadedContent: PostboxCoding, Equatable { } self.author = decoder.decodeOptionalStringForKey("au") self.isMediaLargeByDefault = decoder.decodeOptionalBoolForKey("lbd") + self.imageIsVideoCover = decoder.decodeBoolForKey("isvc", orElse: false) if let image = decoder.decodeObjectForKey("im") as? TelegramMediaImage { self.image = image @@ -331,6 +335,7 @@ public final class TelegramMediaWebpageLoadedContent: PostboxCoding, Equatable { } else { encoder.encodeNil(forKey: "lbd") } + encoder.encodeBool(self.imageIsVideoCover, forKey: "isvc") if let image = self.image { encoder.encodeObject(image, forKey: "im") } else { @@ -377,6 +382,10 @@ public func ==(lhs: TelegramMediaWebpageLoadedContent, rhs: TelegramMediaWebpage return false } + if lhs.imageIsVideoCover != rhs.imageIsVideoCover { + return false + } + if let lhsImage = lhs.image, let rhsImage = rhs.image { if !lhsImage.isEqual(to: rhsImage) { return false diff --git a/submodules/TelegramCore/Sources/WebpagePreview.swift b/submodules/TelegramCore/Sources/WebpagePreview.swift index 1fa282410b..e1b2e8114d 100644 --- a/submodules/TelegramCore/Sources/WebpagePreview.swift +++ b/submodules/TelegramCore/Sources/WebpagePreview.swift @@ -115,6 +115,7 @@ public func webpagePreviewWithProgress(account: Account, urls: [String], webpage duration: nil, author: nil, isMediaLargeByDefault: true, + imageIsVideoCover: false, image: image, file: nil, story: nil, @@ -247,6 +248,7 @@ public func actualizedWebpage(account: Account, webpage: TelegramMediaWebpage) - duration: content.duration, author: content.author, isMediaLargeByDefault: content.isMediaLargeByDefault, + imageIsVideoCover: content.imageIsVideoCover, image: content.image, file: content.file, story: content.story, diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 1e0a50c6a4..9d643cc5ea 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -10972,7 +10972,20 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro } let switchToFilter: (ProfileGiftsContext.Filters) -> Void = { [weak giftsContext] value in - giftsContext?.updateFilter(value) + var updatedFilter = filter + updatedFilter.remove(.unlimited) + updatedFilter.remove(.limited) + updatedFilter.remove(.unique) + updatedFilter.insert(value) + giftsContext?.updateFilter(updatedFilter) + } + + let switchToVisiblityFilter: (ProfileGiftsContext.Filters) -> Void = { [weak giftsContext] value in + var updatedFilter = filter + updatedFilter.remove(.hidden) + updatedFilter.remove(.displayed) + updatedFilter.insert(value) + giftsContext?.updateFilter(updatedFilter) } items.append(.action(ContextMenuActionItem(text: strings.PeerInfo_Gifts_Unlimited, icon: { theme in @@ -11005,14 +11018,14 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro }, action: { _, f in toggleFilter(.displayed) }, longPressAction: { _, f in - switchToFilter(.displayed) + switchToVisiblityFilter(.displayed) }))) items.append(.action(ContextMenuActionItem(text: strings.PeerInfo_Gifts_Hidden, icon: { theme in return filter.contains(.hidden) ? generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor) : nil }, action: { _, f in toggleFilter(.hidden) }, longPressAction: { _, f in - switchToFilter(.hidden) + switchToVisiblityFilter(.hidden) }))) } diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorChatPreviewItem.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorChatPreviewItem.swift index 5c5028f37b..221bd2b1a3 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorChatPreviewItem.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorChatPreviewItem.swift @@ -237,7 +237,7 @@ final class PeerNameColorChatPreviewItemNode: ListViewItemNode { var media: [Media] = [] if let (site, title, text) = messageItem.linkPreview, params.width > 320.0 { - media.append(TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "", displayUrl: "", hash: 0, type: nil, websiteName: site, title: title, text: text, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, image: nil, file: nil, story: nil, attributes: [], instantPage: nil)))) + media.append(TelegramMediaWebpage(webpageId: MediaId(namespace: 0, id: 0), content: .Loaded(TelegramMediaWebpageLoadedContent(url: "", displayUrl: "", hash: 0, type: nil, websiteName: site, title: title, text: text, embedUrl: nil, embedType: nil, embedSize: nil, duration: nil, author: nil, isMediaLargeByDefault: nil, imageIsVideoCover: false, image: nil, file: nil, story: nil, attributes: [], instantPage: nil)))) } let message = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: messageItem.outgoing ? [] : [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: peers[authorPeerId], text: messageItem.text, attributes: messageItem.reply != nil ? [ReplyMessageAttribute(messageId: replyMessageId, threadMessageId: nil, quote: nil, isQuote: false)] : [], media: media, peers: peers, associatedMessages: messages, associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]) diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift index 872397bec6..2c44548509 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift @@ -487,7 +487,6 @@ final class UserAppearanceScreenComponent: Component { guard let self else { return } - let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let navigationController: NavigationController? = self.environment?.controller()?.navigationController as? NavigationController diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift index 3403978568..c28dabc273 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift @@ -586,11 +586,15 @@ public final class StoryPeerListComponent: Component { var titleIconSize: CGSize? if let peerStatus = component.titlePeerStatus { let statusContent: EmojiStatusComponent.Content + var particleColor: UIColor? switch peerStatus { case .premium: statusContent = .premium(color: component.theme.list.itemAccentColor) case let .emoji(emoji): statusContent = .animation(content: .customEmoji(fileId: emoji.fileId), size: CGSize(width: 44.0, height: 44.0), placeholderColor: component.theme.list.mediaPlaceholderColor, themeColor: component.theme.list.itemAccentColor, loopMode: .count(2)) + if let color = emoji.color { + particleColor = UIColor(rgb: UInt32(bitPattern: color)) + } } var animateStatusTransition = false @@ -618,6 +622,7 @@ public final class StoryPeerListComponent: Component { animationCache: component.context.animationCache, animationRenderer: component.context.animationRenderer, content: statusContent, + particleColor: particleColor, isVisibleForAnimations: true, action: { [weak self] in guard let self, let component = self.component, let titleIconView = self.titleIconView?.view else {