[FIX] Duplicate thread message after editing (#14330)

* fix

* renamed method
pull/14339/head
Guilherme Gazzo 6 years ago committed by Rodrigo Nascimento
parent 2210947dde
commit 7fb88e61bf
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
  1. 16
      app/models/server/models/Messages.js
  2. 2
      app/threads/client/flextab/thread.js
  3. 2
      app/threads/client/flextab/threads.js
  4. 2
      app/threads/server/methods/getThreadMessages.js

@ -205,13 +205,25 @@ export class Messages extends Base {
return this.find(query, options);
}
findVisibleByRoomId(roomId, options) {
findVisibleByRoomId(rid, options) {
const query = {
_hidden: {
$ne: true,
},
rid: roomId,
rid,
};
return this.find(query, options);
}
findVisibleThreadByThreadId(tmid, options) {
const query = {
_hidden: {
$ne: true,
},
tmid,
};
return this.find(query, options);

@ -104,7 +104,7 @@ Template.thread.onRendered(function() {
const tmid = this.state.get('tmid');
this.threadsObserve && this.threadsObserve.stop();
this.threadsObserve = Messages.find({ tmid, _updatedAt: { $gt: new Date() } }, {
this.threadsObserve = Messages.find({ tmid, _updatedAt: { $gt: new Date() }, _hidden: { $ne: true } }, {
fields: {
collapsed: 0,
threadMsg: 0,

@ -125,7 +125,7 @@ Template.threads.onCreated(async function() {
this.autorun(() => {
const rid = this.state.get('rid');
this.threadsObserve && this.threadsObserve.stop();
this.threadsObserve = Messages.find({ rid, _updatedAt: { $gt: new Date() }, tcount: { $exists: true } }).observe({
this.threadsObserve = Messages.find({ rid, _updatedAt: { $gt: new Date() }, tcount: { $exists: true }, _hidden: { $ne: true } }).observe({
added: ({ _id, ...message }) => {
this.Threads.upsert({ _id }, message);
}, // Update message to re-render DOM

@ -32,7 +32,7 @@ Meteor.methods({
readThread({ userId: user._id, rid: thread.rid, tmid });
const result = Messages.find({ tmid }, { ...(skip && { skip }), ...(limit && { limit }), sort: { ts : -1 } }).fetch();
const result = Messages.findVisibleThreadByThreadId(tmid, { ...(skip && { skip }), ...(limit && { limit }), sort: { ts : -1 } }).fetch();
return [thread, ...result];
},

Loading…
Cancel
Save