| 3842 | } |
| 3843 | |
| 3844 | void HidePinnedBar( |
| 3845 | not_null<Window::SessionNavigation*> navigation, |
| 3846 | not_null<PeerData*> peer, |
| 3847 | MsgId topicRootId, |
| 3848 | PeerId monoforumPeerId, |
| 3849 | Fn<void()> onHidden) { |
| 3850 | const auto callback = crl::guard(navigation, [=](Fn<void()> &&close) { |
| 3851 | close(); |
| 3852 | auto &session = peer->session(); |
| 3853 | const auto migrated = (topicRootId || monoforumPeerId) |
| 3854 | ? nullptr |
| 3855 | : peer->migrateFrom(); |
| 3856 | const auto top = Data::ResolveTopPinnedId( |
| 3857 | peer, |
| 3858 | topicRootId, |
| 3859 | monoforumPeerId, |
| 3860 | migrated); |
| 3861 | const auto universal = !top |
| 3862 | ? MsgId(0) |
| 3863 | : (migrated && !peerIsChannel(top.peer)) |
| 3864 | ? (top.msg - ServerMaxMsgId) |
| 3865 | : top.msg; |
| 3866 | if (universal) { |
| 3867 | session.settings().setHiddenPinnedMessageId( |
| 3868 | peer->id, |
| 3869 | topicRootId, |
| 3870 | monoforumPeerId, |
| 3871 | universal); |
| 3872 | session.saveSettingsDelayed(); |
| 3873 | if (onHidden) { |
| 3874 | onHidden(); |
| 3875 | } |
| 3876 | } else { |
| 3877 | session.api().requestFullPeer(peer); |
| 3878 | } |
| 3879 | }); |
| 3880 | navigation->parentController()->show( |
| 3881 | Ui::MakeConfirmBox({ |
| 3882 | .text = tr::lng_pinned_hide_all_sure(), |
| 3883 | .confirmed = callback, |
| 3884 | .confirmText = tr::lng_pinned_hide_all_hide(), |
| 3885 | }), |
| 3886 | Ui::LayerOption::CloseOther); |
| 3887 | } |
| 3888 | |
| 3889 | void UnpinAllMessages( |
| 3890 | not_null<Window::SessionNavigation*> navigation, |
no test coverage detected