diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 78b80dfbb2..9faeb8ac77 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -2820,6 +2820,120 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController self.push(PeerInfoStoryGridScreen(context: self.context, peerId: self.context.account.peerId, scope: .archive)) }) }))) + } else if case .channel = peer { + //TODO:localize + items.append(.action(ContextMenuActionItem(text: "Open Channel", icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Channels"), color: theme.contextMenu.primaryColor) + }, action: { [weak self] c, _ in + c.dismiss(completion: { + guard let self else { + return + } + + let _ = (self.context.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: peer.id) + ) + |> deliverOnMainQueue).start(next: { [weak self] peer in + guard let self, let peer else { + return + } + guard let navigationController = self.navigationController as? NavigationController else { + return + } + + self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(peer))) + }) + }) + }))) + + let isMuted = resolvedAreStoriesMuted(globalSettings: globalSettings._asGlobalNotificationSettings(), peer: peer._asPeer(), peerSettings: notificationSettings._asNotificationSettings(), topSearchPeers: topSearchPeers) + items.append(.action(ContextMenuActionItem(text: isMuted ? self.presentationData.strings.StoryFeed_ContextNotifyOn : self.presentationData.strings.StoryFeed_ContextNotifyOff, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: isMuted ? "Chat/Context Menu/Unmute" : "Chat/Context Menu/Muted"), color: theme.contextMenu.primaryColor) + }, action: { [weak self] _, f in + f(.default) + + guard let self else { + return + } + let _ = self.context.engine.peers.togglePeerStoriesMuted(peerId: peer.id).start() + + let iconColor = UIColor.white + let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } + if isMuted { + self.present(UndoOverlayController( + presentationData: presentationData, + content: .universal(animation: "anim_profileunmute", scale: 0.075, colors: [ + "Middle.Group 1.Fill 1": iconColor, + "Top.Group 1.Fill 1": iconColor, + "Bottom.Group 1.Fill 1": iconColor, + "EXAMPLE.Group 1.Fill 1": iconColor, + "Line.Group 1.Stroke 1": iconColor + ], title: nil, text: presentationData.strings.StoryFeed_TooltipNotifyOn(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string, customUndoText: nil, timeout: nil), + elevatedLayout: false, + animateInAsReplacement: false, + action: { _ in return false } + ), in: .current) + } else { + self.present(UndoOverlayController( + presentationData: presentationData, + content: .universal(animation: "anim_profilemute", scale: 0.075, colors: [ + "Middle.Group 1.Fill 1": iconColor, + "Top.Group 1.Fill 1": iconColor, + "Bottom.Group 1.Fill 1": iconColor, + "EXAMPLE.Group 1.Fill 1": iconColor, + "Line.Group 1.Stroke 1": iconColor + ], title: nil, text: presentationData.strings.StoryFeed_TooltipNotifyOff(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string, customUndoText: nil, timeout: nil), + elevatedLayout: false, + animateInAsReplacement: false, + action: { _ in return false } + ), in: .current) + } + }))) + + let hideText: String + if self.location == .chatList(groupId: .archive) { + hideText = self.presentationData.strings.StoryFeed_ContextUnarchive + } else { + hideText = self.presentationData.strings.StoryFeed_ContextArchive + } + let iconName = self.location == .chatList(groupId: .archive) ? "Chat/Context Menu/Unarchive" : "Chat/Context Menu/Archive" + items.append(.action(ContextMenuActionItem(text: hideText, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: iconName), color: theme.contextMenu.primaryColor) + }, action: { [weak self] _, f in + f(.dismissWithoutContent) + + guard let self else { + return + } + let undoValue: Bool + if self.location == .chatList(groupId: .archive) { + self.context.engine.peers.updatePeerStoriesHidden(id: peer.id, isHidden: false) + undoValue = true + } else { + self.context.engine.peers.updatePeerStoriesHidden(id: peer.id, isHidden: true) + undoValue = false + } + + if self.location == .chatList(groupId: .archive) { + self.present(UndoOverlayController(presentationData: self.presentationData, content: .archivedChat(peerId: peer.id.toInt64(), title: "", text: self.presentationData.strings.StoryFeed_TooltipUnarchive(peer.compactDisplayTitle).string, undo: true), elevatedLayout: false, position: .bottom, animateInAsReplacement: false, action: { [weak self] action in + if case .undo = action { + if let self { + self.context.engine.peers.updatePeerStoriesHidden(id: peer.id, isHidden: undoValue) + } + } + return false + }), in: .current) + } else { + self.present(UndoOverlayController(presentationData: self.presentationData, content: .archivedChat(peerId: peer.id.toInt64(), title: "", text: self.presentationData.strings.StoryFeed_TooltipArchive(peer.compactDisplayTitle).string, undo: true), elevatedLayout: false, position: .bottom, animateInAsReplacement: false, action: { [weak self] action in + if case .undo = action { + if let self { + self.context.engine.peers.updatePeerStoriesHidden(id: peer.id, isHidden: undoValue) + } + } + return false + }), in: .current) + } + }))) } else { items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.StoryFeed_ContextOpenChat, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/MessageBubble"), color: theme.contextMenu.primaryColor) diff --git a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift index e8879a99da..3475948d4a 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift @@ -225,7 +225,8 @@ func mergeChannel(lhs: TelegramChannel?, rhs: TelegramChannel) -> TelegramChanne } if case .personal? = rhs.accessHash { - return rhs + let storiesHidden: Bool? = rhs.storiesHidden ?? lhs.storiesHidden + return rhs.withUpdatedStoriesHidden(storiesHidden) } var channelFlags = lhs.flags diff --git a/submodules/TelegramCore/Sources/UpdatePeers.swift b/submodules/TelegramCore/Sources/UpdatePeers.swift index 13a1184433..e53908e1c5 100644 --- a/submodules/TelegramCore/Sources/UpdatePeers.swift +++ b/submodules/TelegramCore/Sources/UpdatePeers.swift @@ -188,9 +188,11 @@ public func updatePeersCustom(transaction: Transaction, peers: [Peer], update: ( updated = mergeChannel(lhs: previous, rhs: updatedChannel) } - let isMember = updatedChannel.participationStatus == .member - if isMember != wasMember || updatedChannel.storiesHidden != wasHidden { - _internal_updateChannelMembership(transaction: transaction, channel: updatedChannel, isMember: isMember) + if let updated = updated as? TelegramChannel { + let isMember = updated.participationStatus == .member + if isMember != wasMember || updated.storiesHidden != wasHidden { + _internal_updateChannelMembership(transaction: transaction, channel: updated, isMember: isMember) + } } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 2629646c12..28895c0aa0 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -1169,8 +1169,6 @@ public final class StoryItemSetContainerComponent: Component { var displayViewLists = false if component.slice.peer.id == component.context.account.peerId { displayViewLists = true - } else if case let .channel(channel) = component.slice.peer, channel.hasPermission(.sendSomething) { - displayViewLists = true } if displayViewLists { @@ -1820,8 +1818,6 @@ public final class StoryItemSetContainerComponent: Component { var displayViewLists = false if component.slice.peer.id == component.context.account.peerId { displayViewLists = true - } else if case let .channel(channel) = component.slice.peer, channel.hasPermission(.sendSomething) { - displayViewLists = true } if displayViewLists { @@ -2966,8 +2962,6 @@ public final class StoryItemSetContainerComponent: Component { var displayViewLists = false if component.slice.peer.id == component.context.account.peerId { displayViewLists = true - } else if case let .channel(channel) = component.slice.peer, channel.hasPermission(.sendSomething) { - displayViewLists = true } if displayViewLists, let currentIndex = component.slice.allItems.firstIndex(where: { $0.storyItem.id == component.slice.item.storyItem.id }) { diff --git a/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift b/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift index cc7058958b..d4025fbde6 100644 --- a/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift @@ -387,9 +387,18 @@ public final class StoryFooterPanelComponent: Component { var likeStatsFrame = CGRect(origin: CGPoint(x: rightContentOffset - reactionStatsLayout.size.width, y: floor((size.height - reactionStatsLayout.size.height) * 0.5)), size: reactionStatsLayout.size) likeStatsFrame.origin.y += component.expandFraction * 45.0 - likeStatsTransition.setFrame(view: likeStatsText, frame: likeStatsFrame) - likeStatsTransition.setAlpha(view: likeStatsText, alpha: 1.0 - component.expandFraction) - rightContentOffset -= reactionStatsLayout.size.width + 1.0 + likeStatsTransition.setPosition(view: likeStatsText, position: likeStatsFrame.center) + likeStatsTransition.setBounds(view: likeStatsText, bounds: CGRect(origin: CGPoint(), size: likeStatsFrame.size)) + var likeStatsAlpha: CGFloat = (1.0 - component.expandFraction) + if reactionCount == 0 { + likeStatsAlpha = 0.0 + } + likeStatsTransition.setAlpha(view: likeStatsText, alpha: likeStatsAlpha) + likeStatsTransition.setScale(view: likeStatsText, scale: reactionCount == 0 ? 0.001 : 1.0) + + if reactionCount != 0 { + rightContentOffset -= reactionStatsLayout.size.width + 1.0 + }f let likeButton: ComponentView if let current = self.likeButton {