MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / addViewAsMessages

Method addViewAsMessages

Telegram/SourceFiles/window/window_peer_menu.cpp:1675–1735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1673}
1674
1675void Filler::addViewAsMessages() {
1676 if (!_peer || !_peer->isForum()) {
1677 return;
1678 }
1679 const auto peer = _peer;
1680 const auto controller = _controller;
1681 const auto parentHideRequests = std::make_shared<rpl::event_stream<>>();
1682 const auto filterOutChatPreview = [=] {
1683 if (base::IsAltPressed()) {
1684 const auto callback = [=](bool shown) {
1685 if (!shown) {
1686 parentHideRequests->fire({});
1687 }
1688 };
1689 controller->showChatPreview({
1690 peer->owner().history(peer),
1691 FullMsgId(),
1692 }, callback, QApplication::activePopupWidget());
1693 return true;
1694 } else if (base::IsCtrlPressed()) {
1695 Ui::PreventDelayedActivation();
1696 controller->showInNewWindow(SeparateId(
1697 SeparateType::Chat,
1698 peer->owner().history(peer)));
1699 return true;
1700 }
1701 return false;
1702 };
1703 const auto open = [=] {
1704 if (const auto forum = peer->forum()) {
1705 peer->owner().saveViewAsMessages(forum, true);
1706 }
1707 controller->showPeerHistory(peer->id);
1708 };
1709 auto to_instant = rpl::map_to(anim::type::instant);
1710 auto make = [=](not_null<Ui::PopupMenu*> popupMenu) {
1711 auto owned = base::make_unique_q<Ui::Menu::Action>(
1712 popupMenu->menu(),
1713 popupMenu->menu()->st(),
1714 Ui::Menu::CreateAction(
1715 popupMenu->menu(),
1716 tr::lng_forum_view_as_messages(tr::now),
1717 [=, weak = base::make_weak(popupMenu)] {
1718 if (filterOutChatPreview()) {
1719 } else {
1720 open();
1721 if (const auto strong = weak.get()) {
1722 strong->hideMenu(false);
1723 }
1724 }
1725 }),
1726 &st::menuIconAsMessages,
1727 &st::menuIconAsMessages);
1728 owned->setPreventClose(true);
1729 return owned;
1730 };
1731 _addAction({
1732 .make = std::move(make),

Callers

nothing calls this directly

Calls 15

showInNewWindowMethod · 0.80
saveViewAsMessagesMethod · 0.80
menuMethod · 0.80
stMethod · 0.80
SeparateIdClass · 0.70
FullMsgIdClass · 0.50
isForumMethod · 0.45
fireMethod · 0.45
showChatPreviewMethod · 0.45
historyMethod · 0.45
ownerMethod · 0.45
forumMethod · 0.45

Tested by

no test coverage detected