Ensure conversation is in left pane when creating a draft message
This commit is contained in:
parent
26ff754896
commit
f914556e4c
1 changed files with 33 additions and 4 deletions
|
@ -1,6 +1,8 @@
|
||||||
// Copyright 2020-2021 Signal Messenger, LLC
|
// Copyright 2020-2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
/* eslint-disable camelcase */
|
||||||
|
|
||||||
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';
|
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';
|
||||||
import { debounce, flatten, omit, throttle } from 'lodash';
|
import { debounce, flatten, omit, throttle } from 'lodash';
|
||||||
import { render } from 'mustache';
|
import { render } from 'mustache';
|
||||||
|
@ -1344,10 +1346,14 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
if (this.model.get('draftChanged')) {
|
if (this.model.get('draftChanged')) {
|
||||||
if (this.model.hasDraft()) {
|
if (this.model.hasDraft()) {
|
||||||
|
const now = Date.now();
|
||||||
|
const active_at = this.model.get('active_at') || now;
|
||||||
|
|
||||||
this.model.set({
|
this.model.set({
|
||||||
|
active_at,
|
||||||
draftChanged: false,
|
draftChanged: false,
|
||||||
draftTimestamp: Date.now(),
|
draftTimestamp: now,
|
||||||
timestamp: Date.now(),
|
timestamp: now,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.model.set({
|
this.model.set({
|
||||||
|
@ -1498,6 +1504,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
const onSave = (caption?: string) => {
|
const onSave = (caption?: string) => {
|
||||||
const attachments = this.model.get('draftAttachments') || [];
|
const attachments = this.model.get('draftAttachments') || [];
|
||||||
|
|
||||||
this.model.set({
|
this.model.set({
|
||||||
draftAttachments: attachments.map((item: AttachmentType) => {
|
draftAttachments: attachments.map((item: AttachmentType) => {
|
||||||
if (item.pending || attachment.pending) {
|
if (item.pending || attachment.pending) {
|
||||||
|
@ -3119,9 +3126,20 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
|
|
||||||
const existing = model.get('quotedMessageId');
|
const existing = model.get('quotedMessageId');
|
||||||
if (existing !== messageId) {
|
if (existing !== messageId) {
|
||||||
|
const now = Date.now();
|
||||||
|
let active_at = this.model.get('active_at');
|
||||||
|
let timestamp = this.model.get('timestamp');
|
||||||
|
|
||||||
|
if (!active_at && messageId) {
|
||||||
|
active_at = now;
|
||||||
|
timestamp = now;
|
||||||
|
}
|
||||||
|
|
||||||
this.model.set({
|
this.model.set({
|
||||||
quotedMessageId: messageId,
|
active_at,
|
||||||
draftChanged: true,
|
draftChanged: true,
|
||||||
|
quotedMessageId: messageId,
|
||||||
|
timestamp,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.saveModel();
|
await this.saveModel();
|
||||||
|
@ -3346,10 +3364,21 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageText !== model.get('draft')) {
|
if (messageText !== model.get('draft')) {
|
||||||
|
const now = Date.now();
|
||||||
|
let active_at = this.model.get('active_at');
|
||||||
|
let timestamp = this.model.get('timestamp');
|
||||||
|
|
||||||
|
if (!active_at) {
|
||||||
|
active_at = now;
|
||||||
|
timestamp = now;
|
||||||
|
}
|
||||||
|
|
||||||
this.model.set({
|
this.model.set({
|
||||||
|
active_at,
|
||||||
draft: messageText,
|
draft: messageText,
|
||||||
draftChanged: true,
|
|
||||||
draftBodyRanges: bodyRanges,
|
draftBodyRanges: bodyRanges,
|
||||||
|
draftChanged: true,
|
||||||
|
timestamp,
|
||||||
});
|
});
|
||||||
await this.saveModel();
|
await this.saveModel();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue