diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index f5381fdff4..fb6831f450 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -14412,3 +14412,9 @@ Sorry for the inconvenience."; "Stars.SendMessage.AdjustmentAction" = "OK"; "Stars.SendMessage.PriceFree" = "Free"; + +"Undo.DeletedMonoforum" = "Removed from your chat list."; + +"Monoforum.DeleteTopic.Title" = "Delete %@"; +"Channel.RemoveFeeAlert.Text" = "Are you sure you want to allow **%@** to message your channel for free?"; +"StarsBalance.ChannelBalance" = "Your channel balance is %@"; diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 3b158005fe..0b9865c4a6 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -5928,7 +5928,9 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController self.chatListDisplayNode.effectiveContainerNode.currentItemNode.setCurrentRemovingItemId(nil) let statusText: String if case let .channel(channel) = chatPeer { - if deleteGloballyIfPossible { + if channel.isMonoForum { + statusText = self.presentationData.strings.Undo_DeletedMonoforum + } else if deleteGloballyIfPossible { if case .broadcast = channel.info { statusText = self.presentationData.strings.Undo_DeletedChannel } else { diff --git a/submodules/Postbox/Sources/PeerView.swift b/submodules/Postbox/Sources/PeerView.swift index 20523451c9..42e37958ad 100644 --- a/submodules/Postbox/Sources/PeerView.swift +++ b/submodules/Postbox/Sources/PeerView.swift @@ -22,6 +22,7 @@ final class MutablePeerView: MutablePostboxView { let components: PeerViewComponents var notificationSettings: PeerNotificationSettings? var cachedData: CachedPeerData? + var associatedCachedData: [PeerId: CachedPeerData] = [:] var peers: [PeerId: Peer] = [:] var peerPresences: [PeerId: PeerPresence] = [:] var messages: [MessageId: Message] = [:] @@ -101,6 +102,10 @@ final class MutablePeerView: MutablePostboxView { } else { self.notificationSettings = postbox.peerNotificationSettingsTable.getEffective(peerId) } + + if let cachedData = postbox.cachedPeerDataTable.get(associatedPeerId) { + self.associatedCachedData[associatedPeerId] = cachedData + } } else { self.notificationSettings = postbox.peerNotificationSettingsTable.getEffective(peerId) } @@ -279,9 +284,35 @@ final class MutablePeerView: MutablePostboxView { updated = true } } - } else if self.notificationSettings != nil { - self.notificationSettings = nil - updated = true + + if let associatedPeerId = peer.associatedPeerId { + if let value = updatedCachedPeerData[associatedPeerId] { + if let current = self.associatedCachedData[associatedPeerId] { + if !current.isEqual(to: value) { + self.associatedCachedData[associatedPeerId] = value + updated = true + } + } else { + self.associatedCachedData[associatedPeerId] = value + updated = true + } + } + } else { + if !self.associatedCachedData.isEmpty { + self.associatedCachedData.removeAll() + updated = true + } + } + } else { + if self.notificationSettings != nil { + self.notificationSettings = nil + updated = true + } + + if !self.associatedCachedData.isEmpty { + self.associatedCachedData.removeAll() + updated = true + } } if let replaceContactPeerIds = replaceContactPeerIds { @@ -377,6 +408,7 @@ public final class PeerView: PostboxView { public let groupId: PeerGroupId? public let storyStats: PeerStoryStats? public let memberStoryStats: [PeerId: PeerStoryStats] + public let associatedCachedData: [PeerId: CachedPeerData] init(_ mutableView: MutablePeerView) { self.peerId = mutableView.peerId @@ -390,5 +422,6 @@ public final class PeerView: PostboxView { self.groupId = mutableView.groupId self.storyStats = mutableView.storyStats self.memberStoryStats = mutableView.memberStoryStats + self.associatedCachedData = mutableView.associatedCachedData } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/RecentlySearchedPeerIds.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/RecentlySearchedPeerIds.swift index f3a600ee9d..6c77d2c4c3 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/RecentlySearchedPeerIds.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/RecentlySearchedPeerIds.swift @@ -79,6 +79,13 @@ public func _internal_recentlySearchedPeers(postbox: Postbox) -> Signal<[Recentl if let peerView = view.views[.peer(peerId: peerId, components: .all)] as? PeerView { var presence: TelegramUserPresence? var unreadCount = unreadCounts[peerId] ?? 0 + var subpeerSummary: RecentlySearchedPeerSubpeerSummary? + + if let cachedData = peerView.cachedData as? CachedChannelData { + let count: Int32 = cachedData.participantsSummary.memberCount ?? 0 + subpeerSummary = RecentlySearchedPeerSubpeerSummary(count: Int(count)) + } + if let peer = peerView.peers[peerId] { if peer is TelegramSecretChat, let associatedPeerId = peer.associatedPeerId { presence = peerView.peerPresences[associatedPeerId] as? TelegramUserPresence @@ -91,6 +98,15 @@ public func _internal_recentlySearchedPeers(postbox: Postbox) -> Signal<[Recentl } else { unreadCount = 0 } + + if channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId { + subpeerSummary = nil + + if let cachedData = peerView.associatedCachedData[linkedMonoforumId] as? CachedChannelData { + let count: Int32 = cachedData.participantsSummary.memberCount ?? 0 + subpeerSummary = RecentlySearchedPeerSubpeerSummary(count: Int(count)) + } + } } if let group = peer as? TelegramGroup, let migrationReference = group.migrationReference { @@ -98,12 +114,6 @@ public func _internal_recentlySearchedPeers(postbox: Postbox) -> Signal<[Recentl } } - var subpeerSummary: RecentlySearchedPeerSubpeerSummary? - if let cachedData = peerView.cachedData as? CachedChannelData { - let count: Int32 = cachedData.participantsSummary.memberCount ?? 0 - subpeerSummary = RecentlySearchedPeerSubpeerSummary(count: Int(count)) - } - result.append(RecentlySearchedPeer(peer: RenderedPeer(peerId: peerId, peers: SimpleDictionary(peerView.peers), associatedMedia: peerView.media), presence: presence, notificationSettings: peerView.notificationSettings as? TelegramPeerNotificationSettings, unreadCount: unreadCount, subpeerSummary: subpeerSummary)) } } diff --git a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift index 9bfa78a43e..b7c09062aa 100644 --- a/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift +++ b/submodules/TelegramUI/Components/AdminUserActionsSheet/Sources/AdminUserActionsSheet.swift @@ -901,11 +901,10 @@ private final class AdminUserActionsSheetComponent: Component { switch component.mode { case .monoforum: if let peer = component.peers.first { - titleString = "Delete \(EnginePeer(peer.peer).compactDisplayTitle)" + titleString = environment.strings.Monoforum_DeleteTopic_Title(EnginePeer(peer.peer).compactDisplayTitle).string } else { titleString = environment.strings.Common_Delete } - //TODO:localize case let .chat(messageCount, deleteAllMessageCount, _): titleString = environment.strings.Chat_AdminActionSheet_DeleteTitle(Int32(messageCount)) if let deleteAllMessageCount { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessagePaymentAlertController/Sources/ChatMessagePaymentAlertController.swift b/submodules/TelegramUI/Components/Chat/ChatMessagePaymentAlertController/Sources/ChatMessagePaymentAlertController.swift index d0cfafa95e..329817b520 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessagePaymentAlertController/Sources/ChatMessagePaymentAlertController.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessagePaymentAlertController/Sources/ChatMessagePaymentAlertController.swift @@ -516,8 +516,7 @@ public func chatMessageRemovePaymentAlertController( let text: String if let context, chatPeer.id != context.account.peerId { - //TODO:localize - text = "Are you sure you want to allow **\(peer.compactDisplayTitle)** to message your channel for free?" + text = strings.Channel_RemoveFeeAlert_Text(peer.compactDisplayTitle).string } else { text = strings.Chat_PaidMessage_RemoveFee_Text(peer.compactDisplayTitle).string } diff --git a/submodules/TelegramUI/Components/ForumSettingsScreen/Sources/ForumModeComponent.swift b/submodules/TelegramUI/Components/ForumSettingsScreen/Sources/ForumModeComponent.swift index 7a1f095ce4..e0194dd234 100644 --- a/submodules/TelegramUI/Components/ForumSettingsScreen/Sources/ForumModeComponent.swift +++ b/submodules/TelegramUI/Components/ForumSettingsScreen/Sources/ForumModeComponent.swift @@ -66,7 +66,6 @@ final class ForumModeComponent: Component { let size = CGSize(width: availableSize.width, height: 224.0) let sideInset = (size.width - 160.0 * 2.0) / 2.0 - //TODO:localize let tabsSize = self.tabs.update( transition: transition, component: AnyComponent( diff --git a/submodules/TelegramUI/Components/Stars/StarsBalanceOverlayComponent/Sources/StarsBalanceOverlayComponent.swift b/submodules/TelegramUI/Components/Stars/StarsBalanceOverlayComponent/Sources/StarsBalanceOverlayComponent.swift index d1e27931c2..197912cf55 100644 --- a/submodules/TelegramUI/Components/Stars/StarsBalanceOverlayComponent/Sources/StarsBalanceOverlayComponent.swift +++ b/submodules/TelegramUI/Components/Stars/StarsBalanceOverlayComponent/Sources/StarsBalanceOverlayComponent.swift @@ -130,8 +130,7 @@ public final class StarsBalanceOverlayComponent: Component { if component.peerId == component.context.account.peerId { rawString = presentationData.strings.StarsBalance_YourBalance("**⭐️\(balance)**").string } else { - //TODO:localize - rawString = "Your channel balance is **⭐️\(balance)**" + rawString = presentationData.strings.StarsBalance_ChannelBalance("**⭐️\(balance)**").string } let attributedText = parseMarkdownIntoAttributedString( diff --git a/submodules/TelegramUI/Sources/ChatControllerContentData.swift b/submodules/TelegramUI/Sources/ChatControllerContentData.swift index d435fbe174..039f2728dd 100644 --- a/submodules/TelegramUI/Sources/ChatControllerContentData.swift +++ b/submodules/TelegramUI/Sources/ChatControllerContentData.swift @@ -1884,7 +1884,10 @@ extension ChatControllerImpl { } strongSelf.initialInterfaceState = (interfaceState, initialEditMessage) + } else { + strongSelf.initialInterfaceState = (ChatInterfaceState(), nil) } + if let readStateData = combinedInitialData.readStateData { if case let .peer(peerId) = chatLocation, let peerReadStateData = readStateData[peerId], let notificationSettings = peerReadStateData.notificationSettings { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift index 3ff34e0a49..43c1e0c53f 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift @@ -235,13 +235,25 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState displayInputTextPanel = true } else if chatPresentationInterfaceState.interfaceState.replyMessageSubject == nil { displayInputTextPanel = false - if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) { - return (currentPanel, nil) + + if !isMember { + if let currentPanel = (currentPanel as? ChatChannelSubscriberInputPanelNode) ?? (currentSecondaryPanel as? ChatChannelSubscriberInputPanelNode) { + return (currentPanel, nil) + } else { + let panel = ChatChannelSubscriberInputPanelNode() + panel.interfaceInteraction = interfaceInteraction + panel.context = context + return (panel, nil) + } } else { - let panel = ChatRestrictedInputPanelNode() - panel.context = context - panel.interfaceInteraction = interfaceInteraction - return (panel, nil) + if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) { + return (currentPanel, nil) + } else { + let panel = ChatRestrictedInputPanelNode() + panel.context = context + panel.interfaceInteraction = interfaceInteraction + return (panel, nil) + } } } } else { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift index b2d9415d67..3aba8f546d 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateNavigationButtons.swift @@ -74,6 +74,13 @@ func leftNavigationButtonForChatInterfaceState(_ presentationInterfaceState: Cha } func rightNavigationButtonForChatInterfaceState(context: AccountContext, presentationInterfaceState: ChatPresentationInterfaceState, strings: PresentationStrings, currentButton: ChatNavigationButton?, target: Any?, selector: Selector?, chatInfoNavigationButton: ChatNavigationButton?, moreInfoNavigationButton: ChatNavigationButton?) -> ChatNavigationButton? { + var hasMessages = false + if let chatHistoryState = presentationInterfaceState.chatHistoryState { + if case .loaded(false, _) = chatHistoryState { + hasMessages = true + } + } + if let _ = presentationInterfaceState.interfaceState.selectionState { if case .messageOptions = presentationInterfaceState.subject { return nil @@ -100,12 +107,18 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present } if let channel = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isMonoForum, case .peer = presentationInterfaceState.chatLocation { - if case .search(false) = currentButton?.action { - return currentButton + let displaySearch = hasMessages + + if displaySearch { + if case .search(false) = currentButton?.action { + return currentButton + } else { + let buttonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(presentationInterfaceState.theme), style: .plain, target: target, action: selector) + buttonItem.accessibilityLabel = strings.Conversation_Search + return ChatNavigationButton(action: .search(hasTags: false), buttonItem: buttonItem) + } } else { - let buttonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(presentationInterfaceState.theme), style: .plain, target: target, action: selector) - buttonItem.accessibilityLabel = strings.Conversation_Search - return ChatNavigationButton(action: .search(hasTags: false), buttonItem: buttonItem) + return nil } } @@ -119,13 +132,6 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present } } - var hasMessages = false - if let chatHistoryState = presentationInterfaceState.chatHistoryState { - if case .loaded(false, _) = chatHistoryState { - hasMessages = true - } - } - if case .messageOptions = presentationInterfaceState.subject { return nil }