From 3e9f242acbd38d4ba84bc73ddd45930d85529db6 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Sun, 5 May 2019 15:09:27 +0400 Subject: [PATCH] ContactListNode: fix queue ordering CreateGroupController: display errors on creation ChatList: use muted mention badges in Archive --- TelegramUI/ChatListItem.swift | 18 +++++++++++++++++- TelegramUI/ContactListNode.swift | 3 ++- TelegramUI/CreateGroupController.swift | 10 ++++++++++ TelegramUI/PresentationResourceKey.swift | 1 + TelegramUI/PresentationResourcesChatList.swift | 6 ++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/TelegramUI/ChatListItem.swift b/TelegramUI/ChatListItem.swift index 332baa3063..d321b70c0d 100644 --- a/TelegramUI/ChatListItem.swift +++ b/TelegramUI/ChatListItem.swift @@ -767,6 +767,18 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { contentImageMedia = file break } + } else if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content { + if let image = content.image { + textLeftCutout += 26.0 + contentImageMedia = image + break + } else if let file = content.file { + if file.isVideo && !file.isInstantVideo { + textLeftCutout += 26.0 + contentImageMedia = file + break + } + } } } } @@ -884,7 +896,11 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { let totalMentionCount = tagSummaryCount - actionsSummaryCount if !isPeerGroup { if totalMentionCount > 0 { - currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundMention(item.presentationData.theme) + if Namespaces.PeerGroup.archive == item.peerGroupId { + currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactiveMention(item.presentationData.theme) + } else { + currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundMention(item.presentationData.theme) + } mentionBadgeContent = .mention } else if item.index.pinningIndex != nil && !isAd && currentBadgeBackgroundImage == nil { currentPinnedIconImage = PresentationResourcesChatList.badgeBackgroundPinned(item.presentationData.theme) diff --git a/TelegramUI/ContactListNode.swift b/TelegramUI/ContactListNode.swift index 184b8a2366..f7639ab2a7 100644 --- a/TelegramUI/ContactListNode.swift +++ b/TelegramUI/ContactListNode.swift @@ -1118,7 +1118,8 @@ final class ContactListNode: ASDisplayNode { |> deliverOnMainQueue } } - self.disposable.set(transition.start(next: { [weak self] transition in + self.disposable.set((transition + |> deliverOnMainQueue).start(next: { [weak self] transition in self?.enqueueTransition(transition) })) diff --git a/TelegramUI/CreateGroupController.swift b/TelegramUI/CreateGroupController.swift index 2c7390c40c..2499c8e132 100644 --- a/TelegramUI/CreateGroupController.swift +++ b/TelegramUI/CreateGroupController.swift @@ -278,6 +278,16 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId]) -> let controller = ChatController(context: context, chatLocation: .peer(peerId)) replaceControllerImpl?(controller) } + }, error: { error in + let presentationData = context.sharedContext.currentPresentationData.with { $0 } + let text: String + switch error { + case .privacy: + text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelMultipleError + case .generic: + text = presentationData.strings.Login_UnknownError + } + presentControllerImpl?(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) })) } }, changeProfilePhoto: { diff --git a/TelegramUI/PresentationResourceKey.swift b/TelegramUI/PresentationResourceKey.swift index deed6a49d9..c90e453b5c 100644 --- a/TelegramUI/PresentationResourceKey.swift +++ b/TelegramUI/PresentationResourceKey.swift @@ -64,6 +64,7 @@ enum PresentationResourceKey: Int32 { case chatListBadgeBackgroundActive case chatListBadgeBackgroundInactive case chatListBadgeBackgroundMention + case chatListBadgeBackgroundInactiveMention case chatListBadgeBackgroundPinned case chatListMutedIcon case chatListVerifiedIcon diff --git a/TelegramUI/PresentationResourcesChatList.swift b/TelegramUI/PresentationResourcesChatList.swift index dd186b64d1..53d1f963e6 100644 --- a/TelegramUI/PresentationResourcesChatList.swift +++ b/TelegramUI/PresentationResourcesChatList.swift @@ -179,6 +179,12 @@ struct PresentationResourcesChatList { }) } + static func badgeBackgroundInactiveMention(_ theme: PresentationTheme) -> UIImage? { + return theme.image(PresentationResourceKey.chatListBadgeBackgroundInactiveMention.rawValue, { theme in + return generateBadgeBackgroundImage(theme: theme, active: false, icon: generateTintedImage(image: UIImage(bundleImageName: "Chat List/MentionBadgeIcon"), color: theme.chatList.unreadBadgeInactiveTextColor)) + }) + } + static func badgeBackgroundPinned(_ theme: PresentationTheme) -> UIImage? { return theme.image(PresentationResourceKey.chatListBadgeBackgroundPinned.rawValue, { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat List/PeerPinnedIcon"), color: theme.chatList.pinnedBadgeColor)