handled a case when user removes downloaded file, minor optimizations on message changing

This commit is contained in:
Blue 2021-04-28 23:26:19 +03:00
parent b44873d587
commit 50190f3eac
23 changed files with 136 additions and 40 deletions

View file

@ -394,18 +394,21 @@ bool Shared::Message::change(const QMap<QString, QVariant>& data)
itr = data.find("body");
if (itr != data.end()) {
QMap<QString, QVariant>::const_iterator dItr = data.find("stamp");
QDateTime correctionDate;
if (dItr != data.end()) {
correctionDate = dItr.value().toDateTime();
} else {
correctionDate = QDateTime::currentDateTimeUtc(); //in case there is no information about time of this correction it's applied
}
if (!edited || lastModified < correctionDate) {
originalMessage = body;
lastModified = correctionDate;
setBody(itr.value().toString());
setEdited(true);
QString b = itr.value().toString();
if (body != b) {
QMap<QString, QVariant>::const_iterator dItr = data.find("stamp");
QDateTime correctionDate;
if (dItr != data.end()) {
correctionDate = dItr.value().toDateTime();
} else {
correctionDate = QDateTime::currentDateTimeUtc(); //in case there is no information about time of this correction it's applied
}
if (!edited || lastModified < correctionDate) {
originalMessage = body;
lastModified = correctionDate;
setBody(body);
setEdited(true);
}
}
}