2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 17:15:16 +00:00

Skip old and currently-sending draft updates.

This commit is contained in:
John Preston
2018-06-08 23:06:26 +03:00
parent 427ceb9a9a
commit cd1c7c56d3
6 changed files with 52 additions and 12 deletions

View File

@@ -51,6 +51,7 @@ constexpr auto kStatusShowClientsideChooseContact = 6000;
constexpr auto kStatusShowClientsidePlayGame = 10000;
constexpr auto kSetMyActionForMs = 10000;
constexpr auto kNewBlockEachMessage = 50;
constexpr auto kSkipCloudDraftsFor = TimeId(3);
void checkForSwitchInlineButton(HistoryItem *item) {
if (item->out() || !item->hasSwitchInlineButton()) {
@@ -405,6 +406,24 @@ Data::Draft *History::createCloudDraft(Data::Draft *fromDraft) {
return cloudDraft();
}
bool History::skipCloudDraft(const QString &text, TimeId date) const {
if (_lastSentDraftText && *_lastSentDraftText == text) {
return true;
} else if (date <= _lastSentDraftTime + kSkipCloudDraftsFor) {
return true;
}
return false;
}
void History::setSentDraftText(const QString &text) {
_lastSentDraftText = text;
}
void History::clearSentDraftText() {
_lastSentDraftText = base::none;
accumulate_max(_lastSentDraftTime, unixtime());
}
void History::setEditDraft(std::unique_ptr<Data::Draft> &&draft) {
_editDraft = std::move(draft);
}