From c7ed688152f9601364435785b65a5fc6cd0735d2 Mon Sep 17 00:00:00 2001 From: Peter Iakovlev Date: Sun, 30 Dec 2018 23:41:30 +0400 Subject: [PATCH 1/3] Fix typo --- TelegramUI/ChatHistoryEntriesForView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TelegramUI/ChatHistoryEntriesForView.swift b/TelegramUI/ChatHistoryEntriesForView.swift index 5a1a1518ad..915e3b3cb6 100644 --- a/TelegramUI/ChatHistoryEntriesForView.swift +++ b/TelegramUI/ChatHistoryEntriesForView.swift @@ -99,7 +99,7 @@ func chatHistoryEntriesForView(location: ChatLocation, view: MessageHistoryView, if let cachedPeerData = cachedPeerData as? CachedUserData, let botInfo = cachedPeerData.botInfo, !botInfo.description.isEmpty { entries.insert(.ChatInfoEntry(botInfo.description, presentationData), at: 0) } - if entries.count == 1, case let .MessageEntry(entry) = view.entries[0] { + if view.entries.count == 1, case let .MessageEntry(entry) = view.entries[0] { if let peer = entry.0.peers[entry.0.id.peerId] as? TelegramGroup, case .creator = peer.role { entries.remove(at: 0) } From 503ae9dc510f3fd1a954a603faaed7f2f4cb5f96 Mon Sep 17 00:00:00 2001 From: Peter Iakovlev Date: Sun, 30 Dec 2018 23:51:32 +0400 Subject: [PATCH 2/3] Another typo --- TelegramUI/ChatHistoryEntriesForView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TelegramUI/ChatHistoryEntriesForView.swift b/TelegramUI/ChatHistoryEntriesForView.swift index 915e3b3cb6..a137e55678 100644 --- a/TelegramUI/ChatHistoryEntriesForView.swift +++ b/TelegramUI/ChatHistoryEntriesForView.swift @@ -99,7 +99,7 @@ func chatHistoryEntriesForView(location: ChatLocation, view: MessageHistoryView, if let cachedPeerData = cachedPeerData as? CachedUserData, let botInfo = cachedPeerData.botInfo, !botInfo.description.isEmpty { entries.insert(.ChatInfoEntry(botInfo.description, presentationData), at: 0) } - if view.entries.count == 1, case let .MessageEntry(entry) = view.entries[0] { + if entries.count == 1, case let .MessageEntry(entry) = entries[0] { if let peer = entry.0.peers[entry.0.id.peerId] as? TelegramGroup, case .creator = peer.role { entries.remove(at: 0) } From d027c6c214d6ce9583159bb5d356997821ac6836 Mon Sep 17 00:00:00 2001 From: Peter Iakovlev Date: Mon, 31 Dec 2018 00:26:58 +0400 Subject: [PATCH 3/3] Added about for regular groups --- TelegramUI/GroupInfoController.swift | 31 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/TelegramUI/GroupInfoController.swift b/TelegramUI/GroupInfoController.swift index b31daa5788..9c26687980 100644 --- a/TelegramUI/GroupInfoController.swift +++ b/TelegramUI/GroupInfoController.swift @@ -765,9 +765,7 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa if canEditGroupInfo { entries.append(GroupInfoEntry.setGroupPhoto(presentationData.theme, presentationData.strings.GroupInfo_SetGroupPhoto)) - if view.peers[view.peerId] is TelegramChannel { - entries.append(GroupInfoEntry.groupDescriptionSetup(presentationData.theme, presentationData.strings.Channel_About_Placeholder, editingState.editingDescriptionText)) - } + entries.append(GroupInfoEntry.groupDescriptionSetup(presentationData.theme, presentationData.strings.Channel_About_Placeholder, editingState.editingDescriptionText)) } if let group = view.peers[view.peerId] as? TelegramGroup { @@ -819,6 +817,11 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa if let peer = view.peers[view.peerId] as? TelegramChannel, let username = peer.username, !username.isEmpty { entries.append(.link(presentationData.theme, "t.me/" + username)) } + } else if let cachedGroupData = view.cachedData as? CachedGroupData { + if let about = cachedGroupData.about, !about.isEmpty { + entries.append(.aboutHeader(presentationData.theme, presentationData.strings.Channel_About_Title.uppercased())) + entries.append(.about(presentationData.theme, about)) + } } entries.append(GroupInfoEntry.notifications(presentationData.theme, presentationData.strings.GroupInfo_Notifications, notificationsText)) @@ -1076,12 +1079,23 @@ private func groupInfoEntries(account: Account, presentationData: PresentationDa private func valuesRequiringUpdate(state: GroupInfoState, view: PeerView) -> (title: String?, description: String?) { if let peer = view.peers[view.peerId] as? TelegramGroup { + var titleValue: String? + var descriptionValue: String? if let editingState = state.editingState { if let title = editingState.editingName?.composedTitle, title != peer.title { - return (title, nil) + titleValue = title + } + if let cachedData = view.cachedData as? CachedGroupData { + if let about = cachedData.about { + if about != editingState.editingDescriptionText { + descriptionValue = editingState.editingDescriptionText + } + } else if !editingState.editingDescriptionText.isEmpty { + descriptionValue = editingState.editingDescriptionText + } } } - return (nil, nil) + return (titleValue, descriptionValue) } else if let peer = view.peers[view.peerId] as? TelegramChannel { var titleValue: String? var descriptionValue: String? @@ -1099,7 +1113,6 @@ private func valuesRequiringUpdate(state: GroupInfoState, view: PeerView) -> (ti } } } - return (titleValue, descriptionValue) } else { return (nil, nil) @@ -1756,8 +1769,12 @@ public func groupInfoController(account: Account, peerId: PeerId) -> ViewControl } else { rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Edit), style: .regular, enabled: true, action: { if let peer = peer as? TelegramGroup { + var text = "" + if let cachedData = view.cachedData as? CachedGroupData, let about = cachedData.about { + text = about + } updateState { state in - return state.withUpdatedEditingState(GroupInfoEditingState(editingName: ItemListAvatarAndNameInfoItemName(peer), editingDescriptionText: "")) + return state.withUpdatedEditingState(GroupInfoEditingState(editingName: ItemListAvatarAndNameInfoItemName(peer), editingDescriptionText: text)) } } else if let channel = peer as? TelegramChannel, case .group = channel.info { var text = ""