2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +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

@@ -214,26 +214,16 @@ void History::draftSavedToCloud() {
if (App::main()) App::main()->writeDrafts(this);
}
SelectedItemSet History::validateForwardDraft() {
auto result = SelectedItemSet();
auto count = 0;
for_const (auto &fullMsgId, _forwardDraft) {
if (auto item = App::histItemById(fullMsgId)) {
result.insert(++count, item);
}
}
HistoryItemsList History::validateForwardDraft() {
auto result = Auth().data().idsToItems(_forwardDraft);
if (result.size() != _forwardDraft.size()) {
setForwardDraft(result);
setForwardDraft(Auth().data().itemsToIds(result));
}
return result;
}
void History::setForwardDraft(const SelectedItemSet &items) {
_forwardDraft.clear();
_forwardDraft.reserve(items.size());
for_const (auto item, items) {
_forwardDraft.push_back(item->fullId());
}
void History::setForwardDraft(MessageIdsList &&items) {
_forwardDraft = std::move(items);
}
bool History::updateSendActionNeedsAnimating(UserData *user, const MTPSendMessageAction &action) {