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

Method addToggleArchive

Telegram/SourceFiles/window/window_peer_menu.cpp:769–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void Filler::addToggleArchive() {
770 if (!_peer
771 || _topic
772 || _request.section == Section::SubsectionTabsMenu) {
773 return;
774 }
775 const auto peer = _peer;
776 const auto history = _request.key.history();
777 if (!CanArchive(history, peer)) {
778 return;
779 }
780 const auto isArchived = [=] {
781 return IsArchived(history);
782 };
783 const auto label = [=] {
784 return isArchived()
785 ? tr::lng_archived_remove(tr::now)
786 : tr::lng_archived_add(tr::now);
787 };
788 const auto toggle = [=, show = _controller->uiShow()] {
789 ToggleHistoryArchived(show, history, !isArchived());
790 };
791 const auto archiveAction = _addAction(
792 label(),
793 toggle,
794 isArchived() ? &st::menuIconUnarchive : &st::menuIconArchive);
795
796 auto actionText = history->session().changes().historyUpdates(
797 history,
798 Data::HistoryUpdate::Flag::Folder
799 ) | rpl::map(label);
800 SetActionText(archiveAction, std::move(actionText));
801}
802
803void Filler::addClearHistory() {
804 if (_topic || _peer->isMonoforum()) {

Callers

nothing calls this directly

Calls 9

CanArchiveFunction · 0.85
IsArchivedFunction · 0.85
ToggleHistoryArchivedFunction · 0.85
SetActionTextFunction · 0.85
historyUpdatesMethod · 0.80
historyMethod · 0.45
uiShowMethod · 0.45
changesMethod · 0.45
sessionMethod · 0.45

Tested by

no test coverage detected