2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-06 01:16:12 +00:00

Support forwarding to monoforums.

This commit is contained in:
John Preston
2025-05-13 18:18:24 +04:00
parent e17bf18350
commit 76db55ff19
36 changed files with 516 additions and 78 deletions

View File

@@ -88,6 +88,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_forum.h"
#include "data/data_forum_topic.h"
#include "data/data_user.h"
#include "data/data_saved_messages.h"
#include "data/data_saved_sublist.h"
#include "data/data_histories.h"
#include "data/data_chat_filters.h"
@@ -435,7 +436,7 @@ void TogglePinnedThread(
: MTPmessages_ToggleSavedDialogPin::Flag(0);
owner->session().api().request(MTPmessages_ToggleSavedDialogPin(
MTP_flags(flags),
MTP_inputDialogPeer(sublist->peer()->input)
MTP_inputDialogPeer(sublist->sublistPeer()->input)
)).done([=] {
owner->notifyPinnedDialogsOrderUpdated();
if (onToggled) {
@@ -655,10 +656,9 @@ void Filler::addNewWindow() {
_addAction(tr::lng_context_new_window(tr::now), [=] {
Ui::PreventDelayedActivation();
if (const auto sublist = weak.get()) {
const auto peer = sublist->peer();
controller->showInNewWindow(SeparateId(
SeparateType::SavedSublist,
peer->owner().history(peer)));
sublist->owner().history(sublist->sublistPeer())));
}
}, &st::menuIconNewWindow);
AddSeparatorAndShiftUp(_addAction);
@@ -2850,6 +2850,46 @@ QPointer<Ui::BoxContent> ShowDropMediaBox(
return weak->data();
}
QPointer<Ui::BoxContent> ShowDropMediaBox(
not_null<Window::SessionNavigation*> navigation,
std::shared_ptr<QMimeData> data,
not_null<Data::SavedMessages*> monoforum,
FnMut<void()> &&successCallback) {
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
auto chosen = [
data = std::move(data),
callback = std::move(successCallback),
weak,
navigation
](not_null<Data::SavedSublist*> sublist) mutable {
const auto content = navigation->parentController()->content();
if (!content->filesOrForwardDrop(sublist, data.get())) {
return;
} else if (const auto strong = *weak) {
strong->closeBox();
}
if (callback) {
callback();
}
};
auto initBox = [=](not_null<PeerListBox*> box) {
box->addButton(tr::lng_cancel(), [=] {
box->closeBox();
});
monoforum->destroyed(
) | rpl::start_with_next([=] {
box->closeBox();
}, box->lifetime());
};
*weak = navigation->parentController()->show(Box<PeerListBox>(
std::make_unique<ChooseSublistBoxController>(
monoforum,
std::move(chosen)),
std::move(initBox)));
return weak->data();
}
QPointer<Ui::BoxContent> ShowSendNowMessagesBox(
not_null<Window::SessionNavigation*> navigation,
not_null<History*> history,