|
|
|
@ -69,6 +69,10 @@ callbacks.add('afterLogoutCleanUp', messageBoxState.purgeAll, callbacks.priority |
|
|
|
|
const showModal = (config) => new Promise((resolve, reject) => modal.open(config, resolve, reject)); |
|
|
|
|
|
|
|
|
|
export class ChatMessages { |
|
|
|
|
constructor(collection = ChatMessage) { |
|
|
|
|
this.collection = collection; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
editing = {} |
|
|
|
|
|
|
|
|
|
records = {} |
|
|
|
@ -113,7 +117,7 @@ export class ChatMessages { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
recordInputAsDraft() { |
|
|
|
|
const message = ChatMessage.findOne(this.editing.id); |
|
|
|
|
const message = this.collection.findOne(this.editing.id); |
|
|
|
|
const record = this.records[this.editing.id] || {}; |
|
|
|
|
const draft = this.input.value; |
|
|
|
|
|
|
|
|
@ -133,7 +137,7 @@ export class ChatMessages { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resetToDraft(id) { |
|
|
|
|
const message = ChatMessage.findOne(id); |
|
|
|
|
const message = this.collection.findOne(id); |
|
|
|
|
const oldValue = this.input.value; |
|
|
|
|
messageBoxState.set(this.input, message.msg); |
|
|
|
|
return oldValue !== message.msg; |
|
|
|
@ -176,7 +180,7 @@ export class ChatMessages { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
edit(element, isEditingTheNextOne) { |
|
|
|
|
const message = ChatMessage.findOne(element.dataset.id); |
|
|
|
|
const message = this.collection.findOne(element.dataset.id); |
|
|
|
|
|
|
|
|
|
const hasPermission = hasAtLeastOnePermission('edit-message', message.rid); |
|
|
|
|
const editAllowed = settings.get('Message_AllowEditing'); |
|
|
|
@ -270,7 +274,7 @@ export class ChatMessages { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// don't add tmid or tshow if the message isn't part of a thread (it can happen if editing the main message of a thread)
|
|
|
|
|
const originalMessage = ChatMessage.findOne({ _id: this.editing.id }, { fields: { tmid: 1 }, reactive: false }); |
|
|
|
|
const originalMessage = this.collection.findOne({ _id: this.editing.id }, { fields: { tmid: 1 }, reactive: false }); |
|
|
|
|
if (originalMessage && tmid && !originalMessage.tmid) { |
|
|
|
|
tmid = undefined; |
|
|
|
|
tshow = undefined; |
|
|
|
@ -298,7 +302,7 @@ export class ChatMessages { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.editing.id) { |
|
|
|
|
const message = ChatMessage.findOne(this.editing.id); |
|
|
|
|
const message = this.collection.findOne(this.editing.id); |
|
|
|
|
const isDescription = message.attachments && message.attachments[0] && message.attachments[0].description; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
@ -352,7 +356,7 @@ export class ChatMessages { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const lastMessage = ChatMessage.findOne({ rid, tmid }, { fields: { ts: 1 }, sort: { ts: -1 } }); |
|
|
|
|
const lastMessage = this.collection.findOne({ rid, tmid }, { fields: { ts: 1 }, sort: { ts: -1 } }); |
|
|
|
|
await call('setReaction', reaction, lastMessage._id); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -440,7 +444,7 @@ export class ChatMessages { |
|
|
|
|
private: true, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
ChatMessage.upsert({ _id: invalidCommandMsg._id }, invalidCommandMsg); |
|
|
|
|
this.collection.upsert({ _id: invalidCommandMsg._id }, invalidCommandMsg); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|