mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Allow topic deletion.
This commit is contained in:
parent
adaa1d0c55
commit
7cdf20a7c5
43 changed files with 144 additions and 64 deletions
|
@ -3518,6 +3518,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_forum_topic_edit" = "Edit Topic";
|
||||
"lng_forum_topic_title" = "Topic Title";
|
||||
"lng_forum_topic_closed" = "This topic is now closed.";
|
||||
"lng_forum_topic_delete" = "Delete";
|
||||
"lng_forum_topic_delete_sure" = "Are you sure you want to delete this topic?";
|
||||
"lng_forum_topics_switch" = "Topics";
|
||||
"lng_forum_no_topics" = "No topics currently created in this forum.";
|
||||
"lng_forum_create_topic" = "Create topic";
|
||||
|
|
|
@ -25,7 +25,7 @@ AttachedStickers::AttachedStickers(not_null<ApiWrap*> api)
|
|||
void AttachedStickers::request(
|
||||
not_null<Window::SessionController*> controller,
|
||||
MTPmessages_GetAttachedStickers &&mtpRequest) {
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
_api.request(_requestId).cancel();
|
||||
_requestId = _api.request(
|
||||
std::move(mtpRequest)
|
||||
|
|
|
@ -83,7 +83,7 @@ void SendBotCallbackData(
|
|||
if (withPassword) {
|
||||
flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_password;
|
||||
}
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
const auto show = std::make_shared<Window::Show>(controller);
|
||||
button->requestId = api->request(MTPmessages_GetBotCallbackAnswer(
|
||||
MTP_flags(flags),
|
||||
|
@ -202,7 +202,7 @@ void SendBotCallbackDataWithPassword(
|
|||
return;
|
||||
}
|
||||
api->cloudPassword().reload();
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
const auto show = std::make_shared<Window::Show>(controller);
|
||||
SendBotCallbackData(controller, item, row, column, std::nullopt, [=](const QString &error) {
|
||||
auto box = PrePasswordErrorBox(
|
||||
|
|
|
@ -107,7 +107,7 @@ void CheckChatInvite(
|
|||
const QString &hash,
|
||||
ChannelData *invitePeekChannel) {
|
||||
const auto session = &controller->session();
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
session->api().checkChatInvite(hash, [=](const MTPChatInvite &result) {
|
||||
Core::App().hideMediaView();
|
||||
result.match([=](const MTPDchatInvite &data) {
|
||||
|
|
|
@ -66,7 +66,7 @@ void ToggleFavedSticker(
|
|||
if (faved && !document->sticker()) {
|
||||
return;
|
||||
}
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
auto done = [=] {
|
||||
document->owner().stickers().setFaved(weak.get(), document, faved);
|
||||
};
|
||||
|
|
|
@ -1815,7 +1815,7 @@ void ApiWrap::sendNotifySettingsUpdates() {
|
|||
}
|
||||
|
||||
void ApiWrap::saveDraftToCloudDelayed(not_null<Data::Thread*> thread) {
|
||||
_draftsSaveRequestIds.emplace(base::make_weak(thread.get()), 0);
|
||||
_draftsSaveRequestIds.emplace(base::make_weak(thread), 0);
|
||||
if (!_draftsSaveTimer.isActive()) {
|
||||
_draftsSaveTimer.callOnce(kSaveCloudDraftTimeout);
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ void FillChooseFilterMenu(
|
|||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<History*> history) {
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
const auto validator = ChooseFilterValidator(history);
|
||||
for (const auto &filter : history->owner().chatsFilters().list()) {
|
||||
const auto id = filter.id();
|
||||
|
|
|
@ -18,7 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/continuous_sliders.h"
|
||||
#include "ui/widgets/box_content_divider.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/toasts/common_toasts.h"
|
||||
#include "info/profile/info_profile_icon.h"
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
|
@ -319,7 +319,7 @@ ChatAdminRights AdminRightsForOwnershipTransfer(bool isGroup) {
|
|||
Fn<void()> AboutGigagroupCallback(
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
|
||||
const auto converting = std::make_shared<bool>();
|
||||
const auto convertSure = [=] {
|
||||
|
@ -333,9 +333,10 @@ Fn<void()> AboutGigagroupCallback(
|
|||
channel->session().api().applyUpdates(result);
|
||||
if (const auto strongController = weak.get()) {
|
||||
strongController->window().hideSettingsAndLayer();
|
||||
Ui::Toast::Show(
|
||||
strongController->widget(),
|
||||
tr::lng_gigagroup_done(tr::now));
|
||||
Ui::ShowMultilineToast({
|
||||
.parentOverride = strongController->widget(),
|
||||
.text = { tr::lng_gigagroup_done(tr::now) },
|
||||
});
|
||||
}
|
||||
}).fail([=] {
|
||||
*converting = false;
|
||||
|
@ -430,7 +431,8 @@ void EditPeerPermissionsBox::prepare() {
|
|||
disabledByAdminRights,
|
||||
tr::lng_rights_permission_cant_edit(tr::now));
|
||||
if (const auto channel = _peer->asChannel()) {
|
||||
if (channel->isPublic()) {
|
||||
if (channel->isPublic()
|
||||
|| (channel->isMegagroup() && channel->linkedChat())) {
|
||||
result.emplace(
|
||||
Flag::ChangeInfo | Flag::PinMessages,
|
||||
tr::lng_rights_permission_unavailable(tr::now));
|
||||
|
@ -732,7 +734,10 @@ EditFlagsControl<Flags> CreateEditFlags(
|
|||
) | rpl::start_with_next([=](bool checked) {
|
||||
if (locked.has_value()) {
|
||||
if (checked != toggled) {
|
||||
Ui::Toast::Show(parent, *locked);
|
||||
Ui::ShowMultilineToast({
|
||||
.parentOverride = parent,
|
||||
.text = { *locked },
|
||||
});
|
||||
control->setChecked(toggled);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1125,7 +1125,7 @@ void Show(
|
|||
}
|
||||
}
|
||||
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
list.push_back({
|
||||
.descriptor = descriptor,
|
||||
.media = (descriptor.requestedSticker
|
||||
|
|
|
@ -1489,7 +1489,7 @@ void ShareGameScoreByHash(
|
|||
if (const auto item = session.data().message(peerId, msgId)) {
|
||||
FastShareMessage(controller, item);
|
||||
} else {
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
const auto resolveMessageAndShareScore = crl::guard(weak, [=](
|
||||
PeerData *peer) {
|
||||
auto done = crl::guard(weak, [=] {
|
||||
|
|
|
@ -193,7 +193,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
|
|||
&st::groupCallInviteMembersList,
|
||||
&st::groupCallMultiSelect);
|
||||
|
||||
const auto weak = base::make_weak(call.get());
|
||||
const auto weak = base::make_weak(call);
|
||||
const auto invite = [=](const std::vector<not_null<UserData*>> &users) {
|
||||
const auto call = weak.get();
|
||||
if (!call) {
|
||||
|
|
|
@ -455,7 +455,7 @@ void LeaveBox(
|
|||
st::boxRowPadding.right(),
|
||||
st::boxRowPadding.bottom()))
|
||||
: nullptr;
|
||||
const auto weak = base::make_weak(call.get());
|
||||
const auto weak = base::make_weak(call);
|
||||
auto label = scheduled
|
||||
? tr::lng_group_call_close()
|
||||
: tr::lng_group_call_leave();
|
||||
|
@ -488,7 +488,7 @@ void FillMenu(
|
|||
Fn<void()> chooseJoinAs,
|
||||
Fn<void()> chooseShareScreenSource,
|
||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox) {
|
||||
const auto weak = base::make_weak(call.get());
|
||||
const auto weak = base::make_weak(call);
|
||||
const auto resolveReal = [=] {
|
||||
const auto real = peer->groupCall();
|
||||
const auto strong = weak.get();
|
||||
|
|
|
@ -2552,7 +2552,7 @@ not_null<Ui::RpWidget*> Panel::widget() const {
|
|||
}
|
||||
|
||||
Show::Show(not_null<Panel*> panel)
|
||||
: _panel(base::make_weak(panel.get())) {
|
||||
: _panel(base::make_weak(panel)) {
|
||||
}
|
||||
|
||||
Show::~Show() = default;
|
||||
|
|
|
@ -244,7 +244,7 @@ void SettingsBox(
|
|||
not_null<GroupCall*> call) {
|
||||
using namespace Settings;
|
||||
|
||||
const auto weakCall = base::make_weak(call.get());
|
||||
const auto weakCall = base::make_weak(call);
|
||||
const auto weakBox = Ui::MakeWeak(box);
|
||||
|
||||
struct State {
|
||||
|
|
|
@ -167,7 +167,7 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) {
|
|||
ActivateClickHandler(window(), activated, {
|
||||
e->button(),
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ void GifsListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
ActivateClickHandler(window(), activated, {
|
||||
e->button(),
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ std::shared_ptr<LargeEmojiImage> EmojiPack::image(EmojiPtr emoji) {
|
|||
}
|
||||
auto result = std::make_shared<LargeEmojiImage>();
|
||||
const auto raw = result.get();
|
||||
const auto weak = base::make_weak(_session.get());
|
||||
const auto weak = base::make_weak(_session);
|
||||
raw->load = [=] {
|
||||
Core::App().emojiImageLoader().with([=](
|
||||
const EmojiImageLoader &loader) {
|
||||
|
|
|
@ -49,7 +49,7 @@ auto LottieCachedFromContent(
|
|||
key,
|
||||
std::move(handler));
|
||||
};
|
||||
const auto weak = base::make_weak(session.get());
|
||||
const auto weak = base::make_weak(session);
|
||||
const auto put = [=](QByteArray &&cached) {
|
||||
crl::on_main(weak, [=, data = std::move(cached)]() mutable {
|
||||
weak->data().cacheBigFile().put(key, std::move(data));
|
||||
|
|
|
@ -769,7 +769,7 @@ void Application::forceLogOut(
|
|||
}));
|
||||
box->setCloseByEscape(false);
|
||||
box->setCloseByOutsideClick(false);
|
||||
const auto weak = base::make_weak(account.get());
|
||||
const auto weak = base::make_weak(account);
|
||||
connect(box, &QObject::destroyed, [=] {
|
||||
crl::on_main(weak, [=] {
|
||||
account->forcedLogOut();
|
||||
|
|
|
@ -930,7 +930,7 @@ void DownloadManager::writePostponed(not_null<Main::Session*> session) {
|
|||
|
||||
Fn<std::optional<QByteArray>()> DownloadManager::serializator(
|
||||
not_null<Main::Session*> session) const {
|
||||
return [this, weak = base::make_weak(session.get())]()
|
||||
return [this, weak = base::make_weak(session)]()
|
||||
-> std::optional<QByteArray> {
|
||||
const auto strong = weak.get();
|
||||
if (!strong) {
|
||||
|
|
|
@ -127,10 +127,13 @@ void Forum::applyReceivedTopics(const MTPmessages_ForumTopics &result) {
|
|||
void Forum::applyTopicDeleted(MsgId rootId) {
|
||||
const auto i = _topics.find(rootId);
|
||||
if (i != end(_topics)) {
|
||||
Core::App().notifications().clearFromTopic(i->second.get());
|
||||
_topicDestroyed.fire(i->second.get());
|
||||
_history->destroyMessagesByTopic(rootId);
|
||||
const auto raw = i->second.get();
|
||||
Core::App().notifications().clearFromTopic(raw);
|
||||
owner().removeChatListEntry(raw);
|
||||
_topicDestroyed.fire(raw);
|
||||
_topics.erase(i);
|
||||
|
||||
_history->destroyMessagesByTopic(rootId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,13 @@ bool ForumTopic::canEdit() const {
|
|||
return (_flags & Flag::My) || channel()->canEditTopics();
|
||||
}
|
||||
|
||||
bool ForumTopic::canDelete() const {
|
||||
return !creating()
|
||||
&& (channel()->canEditTopics()
|
||||
// We don't know if we can delete or not.
|
||||
/*|| ((_flags & Flag::My) && onlyOneMyMessage)*/);
|
||||
}
|
||||
|
||||
bool ForumTopic::canToggleClosed() const {
|
||||
return !creating() && canEdit();
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
[[nodiscard]] bool canEdit() const;
|
||||
[[nodiscard]] bool canToggleClosed() const;
|
||||
[[nodiscard]] bool canTogglePinned() const;
|
||||
[[nodiscard]] bool canDelete() const;
|
||||
|
||||
[[nodiscard]] bool closed() const;
|
||||
void setClosed(bool closed);
|
||||
|
|
|
@ -628,7 +628,7 @@ auto CustomEmojiManager::createLoaderWithSetId(
|
|||
}
|
||||
} else {
|
||||
const auto i = SizeIndex(tag);
|
||||
_loaders[i][documentId].push_back(base::make_weak(result.get()));
|
||||
_loaders[i][documentId].push_back(base::make_weak(result));
|
||||
_pendingForRequest.emplace(documentId);
|
||||
if (!_requestId && _pendingForRequest.size() == 1) {
|
||||
crl::on_main(this, [=] { request(); });
|
||||
|
|
|
@ -1659,7 +1659,7 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
|
|||
? (ElementDelegate*)weak
|
||||
: nullptr;
|
||||
},
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
})
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -1836,7 +1836,7 @@ void HistoryInner::mouseActionFinish(
|
|||
: _mouseActionItem
|
||||
? _mouseActionItem->fullId()
|
||||
: FullMsgId();
|
||||
const auto weak = base::make_weak(_controller.get());
|
||||
const auto weak = base::make_weak(_controller);
|
||||
mouseActionCancel();
|
||||
ActivateClickHandler(
|
||||
window(),
|
||||
|
@ -4176,7 +4176,7 @@ void HistoryInner::onParentGeometryChanged() {
|
|||
|
||||
Fn<HistoryView::ElementDelegate*()> HistoryInner::elementDelegateFactory(
|
||||
FullMsgId itemId) const {
|
||||
const auto weak = base::make_weak(_controller.get());
|
||||
const auto weak = base::make_weak(_controller);
|
||||
return [=]() -> HistoryView::ElementDelegate* {
|
||||
if (const auto strong = weak.get()) {
|
||||
auto &data = strong->session().data();
|
||||
|
@ -4194,7 +4194,7 @@ ClickHandlerContext HistoryInner::prepareClickHandlerContext(
|
|||
return ClickHandlerContext{
|
||||
.itemId = itemId,
|
||||
.elementDelegate = elementDelegateFactory(itemId),
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1439,7 +1439,7 @@ void AddEmojiPacksAction(
|
|||
menu->menu(),
|
||||
menu->st().menu,
|
||||
std::move(text));
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
button->setClickedCallback([=] {
|
||||
const auto strong = weak.get();
|
||||
if (!strong) {
|
||||
|
|
|
@ -3087,7 +3087,7 @@ void ListWidget::mouseActionFinish(
|
|||
? (ElementDelegate*)weak
|
||||
: nullptr;
|
||||
},
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
})
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -2862,7 +2862,7 @@ ClickHandlerPtr Message::rightActionLink() const {
|
|||
savedFromPeer->session().api().requestMessageData(
|
||||
savedFromPeer,
|
||||
savedFromMsgId,
|
||||
[=, weak = base::make_weak(controller.get())] {
|
||||
[=, weak = base::make_weak(controller)] {
|
||||
if (const auto strong = showByThreadWeak.lock()) {
|
||||
if (const auto strongController = weak.get()) {
|
||||
*prequested = 2;
|
||||
|
|
|
@ -578,7 +578,7 @@ void RepliesWidget::setupComposeControls() {
|
|||
const auto topic = _topic
|
||||
? _topic
|
||||
: _history->peer->forumTopicFor(_rootId);
|
||||
return (topic->canToggleClosed() || !topic->closed())
|
||||
return (!topic || topic->canToggleClosed() || !topic->closed())
|
||||
? std::optional<QString>()
|
||||
: tr::lng_forum_topic_closed(tr::now);
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ void FillTextWithAnimatedSpoilers(
|
|||
not_null<Element*> view,
|
||||
Ui::Text::String &text) {
|
||||
if (text.hasSpoilers()) {
|
||||
text.setSpoilerLinkFilter([weak = base::make_weak(view.get())](
|
||||
text.setSpoilerLinkFilter([weak = base::make_weak(view)](
|
||||
const ClickContext &context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
const auto button = context.button;
|
||||
|
|
|
@ -967,7 +967,7 @@ AttachSelectorResult MakeJustSelectorMenu(
|
|||
state.toggling);
|
||||
}, selector->lifetime());
|
||||
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
controller->enableGifPauseReason(
|
||||
Window::GifPauseReason::MediaPreview);
|
||||
QObject::connect(menu.get(), &QObject::destroyed, [weak] {
|
||||
|
@ -1040,7 +1040,7 @@ AttachSelectorResult AttachSelectorToMenu(
|
|||
state.toggling);
|
||||
}, selector->lifetime());
|
||||
|
||||
const auto weak = base::make_weak(controller.get());
|
||||
const auto weak = base::make_weak(controller);
|
||||
controller->enableGifPauseReason(
|
||||
Window::GifPauseReason::MediaPreview);
|
||||
QObject::connect(menu.get(), &QObject::destroyed, [weak] {
|
||||
|
|
|
@ -1726,7 +1726,7 @@ void ListWidget::mouseActionFinish(
|
|||
QVariant::fromValue(ClickHandlerContext{
|
||||
.itemId = fullId,
|
||||
.sessionWindow = base::make_weak(
|
||||
_controller->parentController().get()),
|
||||
_controller->parentController()),
|
||||
})
|
||||
});
|
||||
return;
|
||||
|
|
|
@ -293,7 +293,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
const auto context = ClickContext{
|
||||
button,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(window.get()),
|
||||
.sessionWindow = base::make_weak(window),
|
||||
.peer = peer,
|
||||
})
|
||||
};
|
||||
|
@ -740,7 +740,7 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
|
|||
BotCommandClickHandler('/' + original).onClick(ClickContext{
|
||||
Qt::LeftButton,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(window.get()),
|
||||
.sessionWindow = base::make_weak(window),
|
||||
.peer = user,
|
||||
})
|
||||
});
|
||||
|
|
|
@ -253,7 +253,7 @@ void Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|||
ActivateClickHandler(window(), activated, {
|
||||
e->button(),
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(_controller.get()),
|
||||
.sessionWindow = base::make_weak(_controller),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ MuteItem::MuteItem(
|
|||
st::defaultPopupMenu.showDuration);
|
||||
}, lifetime());
|
||||
|
||||
const auto weak = base::make_weak(thread.get());
|
||||
const auto weak = base::make_weak(thread);
|
||||
setClickedCallback([=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->owner().notifySettings().update(
|
||||
|
@ -161,7 +161,7 @@ void MuteBox(not_null<Ui::GenericBox*> box, not_null<Data::Thread*> thread) {
|
|||
: tr::lng_mute_menu_mute();
|
||||
}) | rpl::flatten_latest();
|
||||
|
||||
const auto weak = base::make_weak(thread.get());
|
||||
const auto weak = base::make_weak(thread);
|
||||
Ui::ConfirmBox(box, {
|
||||
.confirmed = [=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
|
@ -191,7 +191,7 @@ void PickMuteBox(
|
|||
|
||||
const auto pickerCallback = TimePickerBox(box, seconds, phrases, 0);
|
||||
|
||||
const auto weak = base::make_weak(thread.get());
|
||||
const auto weak = base::make_weak(thread);
|
||||
Ui::ConfirmBox(box, {
|
||||
.confirmed = [=] {
|
||||
const auto muteFor = pickerCallback();
|
||||
|
@ -240,7 +240,7 @@ void FillMuteMenu(
|
|||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<Data::Thread*> thread,
|
||||
std::shared_ptr<Ui::Show> show) {
|
||||
const auto weak = base::make_weak(thread.get());
|
||||
const auto weak = base::make_weak(thread);
|
||||
const auto with = [=](Fn<void(not_null<Data::Thread*> thread)> handler) {
|
||||
return [=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
|
|
|
@ -225,7 +225,7 @@ void SetupUnreadMentionsMenu(
|
|||
const auto sendRequest = [=](
|
||||
not_null<Data::Thread*> thread,
|
||||
Fn<void()> done) {
|
||||
sendOne(base::make_weak(thread.get()), std::move(done), sendOne);
|
||||
sendOne(base::make_weak(thread), std::move(done), sendOne);
|
||||
};
|
||||
SetupReadAllMenu(button, currentThread, text, sendRequest);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ void SetupUnreadReactionsMenu(
|
|||
const auto sendRequest = [=](
|
||||
not_null<Data::Thread*> thread,
|
||||
Fn<void()> done) {
|
||||
sendOne(base::make_weak(thread.get()), std::move(done), sendOne);
|
||||
sendOne(base::make_weak(thread), std::move(done), sendOne);
|
||||
};
|
||||
SetupReadAllMenu(button, currentThread, text, sendRequest);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ DoneHandler ConcurrentSender::HandlerMaker::MakeDone(
|
|||
not_null<ConcurrentSender*> sender,
|
||||
Fn<void(FnMut<void()>)> runner) {
|
||||
return [
|
||||
weak = base::make_weak(sender.get()),
|
||||
weak = base::make_weak(sender),
|
||||
runner = std::move(runner)
|
||||
](const Response &response) mutable {
|
||||
runner([=]() mutable {
|
||||
|
@ -47,7 +47,7 @@ FailHandler ConcurrentSender::HandlerMaker::MakeFail(
|
|||
Fn<void(FnMut<void()>)> runner,
|
||||
FailSkipPolicy skipPolicy) {
|
||||
return [
|
||||
weak = base::make_weak(sender.get()),
|
||||
weak = base::make_weak(sender),
|
||||
runner = std::move(runner),
|
||||
skipPolicy
|
||||
](const Error &error, const Response &response) mutable {
|
||||
|
|
|
@ -988,7 +988,7 @@ TopBar::TopBar(
|
|||
ActivateClickHandler(_about, handler, {
|
||||
button,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(controller.get()),
|
||||
.sessionWindow = base::make_weak(controller),
|
||||
.botStartAutoSubmit = true,
|
||||
})
|
||||
});
|
||||
|
@ -1795,7 +1795,7 @@ not_null<Ui::GradientButton*> CreateSubscribeButton(
|
|||
UrlClickHandler::Open(
|
||||
local,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.sessionWindow = base::make_weak(controller.get()),
|
||||
.sessionWindow = base::make_weak(controller),
|
||||
.botStartAutoSubmit = true,
|
||||
}));
|
||||
} else {
|
||||
|
|
|
@ -176,7 +176,7 @@ void Account::startAdded(MTP::AuthKeyPtr localKey) {
|
|||
}
|
||||
|
||||
void Account::clearLegacyFiles() {
|
||||
const auto weak = base::make_weak(_owner.get());
|
||||
const auto weak = base::make_weak(_owner);
|
||||
ClearLegacyFiles(_basePath, [weak, this](
|
||||
FnMut<void(base::flat_set<QString>&&)> then) {
|
||||
crl::on_main(weak, [this, then = std::move(then)]() mutable {
|
||||
|
|
|
@ -155,7 +155,7 @@ void PeerMenuAddMuteSubmenuAction(
|
|||
const PeerMenuCallback &addAction) {
|
||||
const auto notifySettings = &thread->owner().notifySettings();
|
||||
notifySettings->request(thread);
|
||||
const auto weak = base::make_weak(thread.get());
|
||||
const auto weak = base::make_weak(thread);
|
||||
const auto with = [=](Fn<void(not_null<Data::Thread*>)> callback) {
|
||||
return [=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
|
@ -830,12 +830,24 @@ void Filler::addDeleteContact() {
|
|||
}
|
||||
|
||||
void Filler::addDeleteTopic() {
|
||||
if (!_topic/* || !_topic->canDelete()*/) {
|
||||
if (!_topic || !_topic->canDelete()) {
|
||||
return;
|
||||
}
|
||||
const auto controller = _controller;
|
||||
const auto weak = base::make_weak(_topic);
|
||||
const auto callback = [=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
PeerMenuDeleteTopicWithConfirmation(controller, strong);
|
||||
}
|
||||
};
|
||||
_addAction({
|
||||
.text = tr::lng_forum_topic_delete(tr::now),
|
||||
.handler = callback,
|
||||
.icon = &st::menuIconDeleteAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Filler::addManageTopic() {
|
||||
if (!_topic || !_topic->canEdit()) {
|
||||
return;
|
||||
|
@ -971,6 +983,7 @@ void Filler::addCreateTopic() {
|
|||
}
|
||||
const auto peer = _peer;
|
||||
const auto controller = _controller;
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
_addAction(tr::lng_forum_create_topic(tr::now), [=] {
|
||||
if (const auto forum = peer->forum()) {
|
||||
controller->show(Box(
|
||||
|
@ -979,7 +992,6 @@ void Filler::addCreateTopic() {
|
|||
forum->history()));
|
||||
}
|
||||
}, &st::menuIconDiscussion);
|
||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||
}
|
||||
|
||||
void Filler::addViewAsMessages() {
|
||||
|
@ -1004,7 +1016,6 @@ void Filler::fillChatsListActions() {
|
|||
if (!_peer || !_peer->isForum()) {
|
||||
return;
|
||||
}
|
||||
addCreateTopic();
|
||||
addViewAsMessages();
|
||||
addInfo();
|
||||
addNewMembers();
|
||||
|
@ -1017,6 +1028,7 @@ void Filler::fillChatsListActions() {
|
|||
} else {
|
||||
addJoinChat();
|
||||
}
|
||||
addCreateTopic();
|
||||
}
|
||||
|
||||
void Filler::fillContextMenuActions() {
|
||||
|
@ -1082,10 +1094,10 @@ void Filler::fillRepliesActions() {
|
|||
addInfo();
|
||||
addManageTopic();
|
||||
addManageChat();
|
||||
addDeleteTopic();
|
||||
}
|
||||
addCreatePoll();
|
||||
addToggleTopicClosed();
|
||||
addDeleteTopic();
|
||||
}
|
||||
|
||||
void Filler::fillScheduledActions() {
|
||||
|
@ -1159,6 +1171,49 @@ void PeerMenuDeleteContact(
|
|||
Ui::LayerOption::CloseOther);
|
||||
}
|
||||
|
||||
|
||||
void PeerMenuDeleteTopicWithConfirmation(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<Data::ForumTopic*> topic) {
|
||||
const auto weak = base::make_weak(topic);
|
||||
const auto callback = [=](Fn<void()> &&close) {
|
||||
close();
|
||||
if (const auto strong = weak.get()) {
|
||||
PeerMenuDeleteTopic(navigation, strong);
|
||||
}
|
||||
};
|
||||
navigation->parentController()->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_forum_topic_delete_sure(tr::now),
|
||||
.confirmed = callback,
|
||||
.confirmText = tr::lng_box_delete(),
|
||||
.confirmStyle = &st::attentionBoxButton,
|
||||
}));
|
||||
}
|
||||
|
||||
void PeerMenuDeleteTopic(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<ChannelData*> channel,
|
||||
MsgId rootId) {
|
||||
const auto api = &channel->session().api();
|
||||
api->request(MTPchannels_DeleteTopicHistory(
|
||||
channel->inputChannel,
|
||||
MTP_int(rootId)
|
||||
)).done([=](const MTPmessages_AffectedHistory &result) {
|
||||
const auto offset = api->applyAffectedHistory(channel, result);
|
||||
if (offset > 0) {
|
||||
PeerMenuDeleteTopic(navigation, channel, rootId);
|
||||
} else if (const auto forum = channel->forum()) {
|
||||
forum->applyTopicDeleted(rootId);
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
||||
void PeerMenuDeleteTopic(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<Data::ForumTopic*> topic) {
|
||||
PeerMenuDeleteTopic(navigation, topic->channel(), topic->rootId());
|
||||
}
|
||||
|
||||
void PeerMenuShareContactBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> user) {
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Data {
|
|||
class Folder;
|
||||
class Session;
|
||||
struct ForwardDraft;
|
||||
class ForumTopic;
|
||||
} // namespace Data
|
||||
|
||||
namespace Dialogs {
|
||||
|
@ -74,6 +75,12 @@ void PeerMenuCreatePoll(
|
|||
PollData::Flags disabled = PollData::Flags(),
|
||||
Api::SendType sendType = Api::SendType::Normal,
|
||||
SendMenu::Type sendMenuType = SendMenu::Type::Scheduled);
|
||||
void PeerMenuDeleteTopicWithConfirmation(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<Data::ForumTopic*> topic);
|
||||
void PeerMenuDeleteTopic(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<Data::ForumTopic*> topic);
|
||||
|
||||
struct ClearChat {
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2a94813b6aa1f8645fd9de88a78981356259fab7
|
||||
Subproject commit 12814dcf5067d687c47c710689902fd1219bec4f
|
Loading…
Add table
Reference in a new issue