Various improvements

This commit is contained in:
Isaac 2025-06-06 15:13:43 +08:00
parent e53af6f87d
commit cd3c27fcc2
11 changed files with 103 additions and 35 deletions

View File

@ -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 %@";

View File

@ -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 {

View File

@ -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
}
}

View File

@ -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))
}
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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(

View File

@ -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(

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}