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:
@@ -450,21 +450,11 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||
|
||||
DeleteMessagesBox::DeleteMessagesBox(
|
||||
QWidget*,
|
||||
const SelectedItemSet &selected)
|
||||
: _ids(CollectFrom(selected)) {
|
||||
MessageIdsList &&selected)
|
||||
: _ids(std::move(selected)) {
|
||||
Expects(!_ids.empty());
|
||||
}
|
||||
|
||||
std::vector<FullMsgId> DeleteMessagesBox::CollectFrom(
|
||||
const SelectedItemSet &items) {
|
||||
return ranges::make_iterator_range(
|
||||
items.begin(),
|
||||
items.end()
|
||||
) | ranges::view::transform([](not_null<HistoryItem*> item) {
|
||||
return item->fullId();
|
||||
}) | ranges::to_vector;
|
||||
}
|
||||
|
||||
void DeleteMessagesBox::prepare() {
|
||||
auto text = QString();
|
||||
if (_moderateFrom) {
|
||||
|
@@ -177,7 +177,7 @@ public:
|
||||
QWidget*,
|
||||
not_null<HistoryItem*> item,
|
||||
bool suggestModerateActions);
|
||||
DeleteMessagesBox(QWidget*, const SelectedItemSet &selected);
|
||||
DeleteMessagesBox(QWidget*, MessageIdsList &&selected);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
@@ -188,9 +188,7 @@ protected:
|
||||
private:
|
||||
void deleteAndClear();
|
||||
|
||||
static std::vector<FullMsgId> CollectFrom(const SelectedItemSet &items);
|
||||
|
||||
const std::vector<FullMsgId> _ids;
|
||||
const MessageIdsList _ids;
|
||||
const bool _singleItem = false;
|
||||
UserData *_moderateFrom = nullptr;
|
||||
ChannelData *_moderateInChannel = nullptr;
|
||||
|
@@ -892,7 +892,7 @@ void AddBotToGroupBoxController::prepareViewHook() {
|
||||
}
|
||||
|
||||
ChooseRecipientBoxController::ChooseRecipientBoxController(
|
||||
base::lambda<void(not_null<PeerData*>)> callback)
|
||||
base::lambda_once<void(not_null<PeerData*>)> callback)
|
||||
: _callback(std::move(callback)) {
|
||||
}
|
||||
|
||||
|
@@ -243,7 +243,7 @@ private:
|
||||
class ChooseRecipientBoxController : public ChatsListBoxController {
|
||||
public:
|
||||
ChooseRecipientBoxController(
|
||||
base::lambda<void(not_null<PeerData*>)> callback);
|
||||
base::lambda_once<void(not_null<PeerData*>)> callback);
|
||||
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
@@ -257,6 +257,6 @@ protected:
|
||||
not_null<History*> history) override;
|
||||
|
||||
private:
|
||||
base::lambda<void(not_null<PeerData*>)> _callback;
|
||||
base::lambda_once<void(not_null<PeerData*>)> _callback;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user