| 767 | } |
| 768 | |
| 769 | void 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 | |
| 803 | void Filler::addClearHistory() { |
| 804 | if (_topic || _peer->isMonoforum()) { |
nothing calls this directly
no test coverage detected