2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Replace SelectedItemSet with MessageIdsList.

Use vector<FullMsgId> everywhere instead QMap<..,HistoryItem*>.
The old way the app crashed in case some messages were deleted.
If the items are needed use HistoryItemsList=vector<HistoryItem*>.
This commit is contained in:
John Preston
2017-12-06 14:13:38 +04:00
parent 3845985a6b
commit 6764a3cc86
25 changed files with 269 additions and 248 deletions

View File

@@ -28,6 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "boxes/peer_list_controllers.h"
#include "boxes/peers/manage_peer_box.h"
#include "boxes/peers/edit_peer_info_box.h"
#include "ui/toast/toast.h"
#include "core/tl_help.h"
#include "auth_session.h"
#include "apiwrap.h"
@@ -492,6 +493,37 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
}));
}
void ShowForwardMessagesBox(
MessageIdsList &&items,
base::lambda_once<void()> &&successCallback) {
auto weak = std::make_shared<QPointer<PeerListBox>>();
auto callback = [
ids = std::move(items),
callback = std::move(successCallback),
weak
](not_null<PeerData*> peer) mutable {
if (peer->isSelf()) {
Ui::Toast::Show(lang(lng_share_done));
} else {
App::main()->setForwardDraft(peer->id, std::move(ids));
}
if (const auto strong = *weak) {
strong->closeBox();
}
if (callback) {
callback();
}
};
auto initBox = [](not_null<PeerListBox*> box) {
box->addButton(langFactory(lng_cancel), [box] {
box->closeBox();
});
};
*weak = Ui::show(Box<PeerListBox>(
std::make_unique<ChooseRecipientBoxController>(std::move(callback)),
std::move(initBox)), LayerOption::KeepOther);
}
void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) {
if (channel->isMegagroup()) {
auto &participants = channel->mgInfo->lastParticipants;