From 9381802bf41bc96f373d1edb6b264f3dc0b7a731 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Thu, 19 Aug 2021 14:19:39 +0300 Subject: [PATCH] View discussion button --- src/components/chat/chat.ts | 2 +- src/components/chat/topbar.ts | 25 ++++++++++++++++++++++++- src/lang.ts | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/components/chat/chat.ts b/src/components/chat/chat.ts index 10e2dc48..c76d9606 100644 --- a/src/components/chat/chat.ts +++ b/src/components/chat/chat.ts @@ -173,7 +173,7 @@ export default class Chat extends EventListenerBase<{ public init(/* peerId: number */) { // this.initPeerId = peerId; - this.topbar = new ChatTopbar(this, appSidebarRight, this.appMessagesManager, this.appPeersManager, this.appChatsManager, this.appNotificationsManager); + this.topbar = new ChatTopbar(this, appSidebarRight, this.appMessagesManager, this.appPeersManager, this.appChatsManager, this.appNotificationsManager, this.appProfileManager); this.bubbles = new ChatBubbles(this, this.appMessagesManager, this.appStickersManager, this.appUsersManager, this.appInlineBotsManager, this.appPhotosManager, this.appPeersManager, this.appProfileManager, this.appDraftsManager, this.appMessagesIdsManager); this.input = new ChatInput(this, this.appMessagesManager, this.appMessagesIdsManager, this.appDocsManager, this.appChatsManager, this.appPeersManager, this.appWebPagesManager, this.appImManager, this.appDraftsManager, this.serverTimeManager, this.appNotificationsManager, this.appEmojiManager, this.appUsersManager, this.appInlineBotsManager); this.selection = new ChatSelection(this, this.bubbles, this.input, this.appMessagesManager); diff --git a/src/components/chat/topbar.ts b/src/components/chat/topbar.ts index 20701ba5..e0583e0c 100644 --- a/src/components/chat/topbar.ts +++ b/src/components/chat/topbar.ts @@ -9,6 +9,7 @@ import type { AppChatsManager, Channel } from "../../lib/appManagers/appChatsMan import type { AppMessagesManager } from "../../lib/appManagers/appMessagesManager"; import type { AppPeersManager } from "../../lib/appManagers/appPeersManager"; import type { AppSidebarRight } from "../sidebarRight"; +import type { AppProfileManager } from "../../lib/appManagers/appProfileManager"; import type Chat from "./chat"; import { RIGHT_COLUMN_ACTIVE_CLASSNAME } from "../sidebarRight"; import mediaSizes, { ScreenSize } from "../../helpers/mediaSizes"; @@ -35,6 +36,7 @@ import { attachClickEvent } from "../../helpers/dom/clickEvent"; import findUpTag from "../../helpers/dom/findUpTag"; import { toast } from "../toast"; import replaceContent from "../../helpers/dom/replaceContent"; +import { ChatFull } from "../../layer"; export default class ChatTopbar { public container: HTMLDivElement; @@ -62,7 +64,14 @@ export default class ChatTopbar { private menuButtons: (ButtonMenuItemOptions & {verify: () => boolean})[] = []; - constructor(private chat: Chat, private appSidebarRight: AppSidebarRight, private appMessagesManager: AppMessagesManager, private appPeersManager: AppPeersManager, private appChatsManager: AppChatsManager, private appNotificationsManager: AppNotificationsManager) { + constructor(private chat: Chat, + private appSidebarRight: AppSidebarRight, + private appMessagesManager: AppMessagesManager, + private appPeersManager: AppPeersManager, + private appChatsManager: AppChatsManager, + private appNotificationsManager: AppNotificationsManager, + private appProfileManager: AppProfileManager + ) { this.listenerSetter = new ListenerSetter(); } @@ -215,6 +224,20 @@ export default class ChatTopbar { this.appMessagesManager.mutePeer(this.peerId); }, verify: () => this.chat.type === 'chat' && rootScope.myId !== this.peerId && this.appNotificationsManager.isPeerLocalMuted(this.peerId, false) + }, { + icon: 'comments', + text: 'ViewDiscussion', + onClick: () => { + this.appProfileManager.getChannelFull(-this.peerId).then(channelFull => { + if(channelFull.linked_chat_id) { + this.chat.appImManager.setInnerPeer(-channelFull.linked_chat_id); + } + }); + }, + verify: () => { + const chatFull = this.appProfileManager.chatsFull[-this.peerId]; + return this.chat.type === 'chat' && this.appPeersManager.isBroadcast(this.peerId) && !!(chatFull as ChatFull.channelFull)?.linked_chat_id; + } }, { icon: 'select', text: 'Chat.Menu.SelectMessages', diff --git a/src/lang.ts b/src/lang.ts index c1c2af97..3fa0ee93 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -547,6 +547,7 @@ const lang = { "ViewInChat": "View in chat", "LinkNotFound": "Unfortunately, you can\'t access this message. You are not a member of the chat where it was posted.", "Create": "Create", + "ViewDiscussion": "View discussion", // * macos "AccountSettings.Filters": "Chat Folders",