mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +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:
@@ -38,6 +38,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/search_field_controller.h"
|
||||
#include "window/window_peer_menu.h"
|
||||
|
||||
namespace Info {
|
||||
|
||||
@@ -489,14 +490,14 @@ bool TopBar::searchMode() const {
|
||||
return _searchModeAvailable && _searchModeEnabled;
|
||||
}
|
||||
|
||||
SelectedItemSet TopBar::collectItems() const {
|
||||
auto result = SelectedItemSet();
|
||||
for (auto value : _selectedItems.list) {
|
||||
if (auto item = App::histItemById(value.msgId)) {
|
||||
result.insert(result.size(), item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
MessageIdsList TopBar::collectItems() const {
|
||||
return ranges::view::all(
|
||||
_selectedItems.list
|
||||
) | ranges::view::transform([](auto &&item) {
|
||||
return item.msgId;
|
||||
}) | ranges::view::filter([](const FullMsgId &msgId) {
|
||||
return App::histItemById(msgId) != nullptr;
|
||||
}) | ranges::to_vector;
|
||||
}
|
||||
|
||||
void TopBar::performForward() {
|
||||
@@ -505,20 +506,11 @@ void TopBar::performForward() {
|
||||
_cancelSelectionClicks.fire({});
|
||||
return;
|
||||
}
|
||||
auto callback = [items = std::move(items), weak = make_weak(this)](
|
||||
not_null<PeerData*> peer) {
|
||||
App::main()->setForwardDraft(peer->id, items);
|
||||
Window::ShowForwardMessagesBox(std::move(items), [weak = make_weak(this)]{
|
||||
if (weak) {
|
||||
weak->_cancelSelectionClicks.fire({});
|
||||
}
|
||||
};
|
||||
Ui::show(Box<PeerListBox>(
|
||||
std::make_unique<ChooseRecipientBoxController>(std::move(callback)),
|
||||
[](not_null<PeerListBox*> box) {
|
||||
box->addButton(langFactory(lng_cancel), [box] {
|
||||
box->closeBox();
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
void TopBar::performDelete() {
|
||||
@@ -526,7 +518,7 @@ void TopBar::performDelete() {
|
||||
if (items.empty()) {
|
||||
_cancelSelectionClicks.fire({});
|
||||
} else {
|
||||
Ui::show(Box<DeleteMessagesBox>(items));
|
||||
Ui::show(Box<DeleteMessagesBox>(std::move(items)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user