2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Display occupied chats using drafts for support.

This commit is contained in:
John Preston
2018-11-15 19:36:04 +04:00
parent 60103f7ad6
commit 4960e08a24
20 changed files with 429 additions and 95 deletions

View File

@@ -3840,13 +3840,14 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
void MainWidget::saveDraftToCloud() {
_history->saveFieldToHistoryLocalDraft();
auto peer = _history->peer();
if (auto history = App::historyLoaded(peer)) {
const auto peer = _history->peer();
if (const auto history = App::historyLoaded(peer)) {
writeDrafts(history);
auto localDraft = history->localDraft();
auto cloudDraft = history->cloudDraft();
if (!Data::draftsAreEqual(localDraft, cloudDraft)) {
const auto localDraft = history->localDraft();
const auto cloudDraft = history->cloudDraft();
if (!Data::draftsAreEqual(localDraft, cloudDraft)
&& !Auth().supportMode()) {
Auth().api().saveDraftToCloudDelayed(history);
}
}
@@ -3859,17 +3860,27 @@ void MainWidget::applyCloudDraft(History *history) {
void MainWidget::writeDrafts(History *history) {
Local::MessageDraft storedLocalDraft, storedEditDraft;
MessageCursor localCursor, editCursor;
if (auto localDraft = history->localDraft()) {
if (!Data::draftsAreEqual(localDraft, history->cloudDraft())) {
storedLocalDraft = Local::MessageDraft(localDraft->msgId, localDraft->textWithTags, localDraft->previewCancelled);
if (const auto localDraft = history->localDraft()) {
if (Auth().supportMode()
|| !Data::draftsAreEqual(localDraft, history->cloudDraft())) {
storedLocalDraft = Local::MessageDraft(
localDraft->msgId,
localDraft->textWithTags,
localDraft->previewCancelled);
localCursor = localDraft->cursor;
}
}
if (auto editDraft = history->editDraft()) {
storedEditDraft = Local::MessageDraft(editDraft->msgId, editDraft->textWithTags, editDraft->previewCancelled);
if (const auto editDraft = history->editDraft()) {
storedEditDraft = Local::MessageDraft(
editDraft->msgId,
editDraft->textWithTags,
editDraft->previewCancelled);
editCursor = editDraft->cursor;
}
Local::writeDrafts(history->peer->id, storedLocalDraft, storedEditDraft);
Local::writeDrafts(
history->peer->id,
storedLocalDraft,
storedEditDraft);
Local::writeDraftCursors(history->peer->id, localCursor, editCursor);
}