diff --git a/app/threads/client/flextab/thread.js b/app/threads/client/flextab/thread.js index a97e8fd94474..db96703a4a5a 100644 --- a/app/threads/client/flextab/thread.js +++ b/app/threads/client/flextab/thread.js @@ -63,9 +63,10 @@ Template.thread.helpers({ }, messageBoxData() { const instance = Template.instance(); - const { mainMessage: { rid, _id: tmid } } = this; + const { mainMessage: { rid, _id: tmid }, subscription } = this; return { + subscription, rid, tmid, onSend: (...args) => instance.chatMessages && instance.chatMessages.send.apply(instance.chatMessages, args), diff --git a/app/threads/client/flextab/threads.js b/app/threads/client/flextab/threads.js index 83d04a14e032..4ff0385f3aeb 100644 --- a/app/threads/client/flextab/threads.js +++ b/app/threads/client/flextab/threads.js @@ -37,6 +37,9 @@ Template.threads.events({ }); Template.threads.helpers({ + subscription() { + return Template.instance().data.subscription; + }, doDotLoadThreads() { return Template.instance().state.get('close'); }, diff --git a/app/ui-message/client/message.js b/app/ui-message/client/message.js index 05044e2fa3b0..26239a589952 100644 --- a/app/ui-message/client/message.js +++ b/app/ui-message/client/message.js @@ -445,13 +445,7 @@ const findParentMessage = (() => { }, }, { multi: true }); if (!Messages.findOne({ _id })) { - /** - * Delete rid from message to not render it and to not be considred in last message - * find from load history method what was preveting the load of some messages in - * between the reals last loaded message and this one if this one is older than - * the real last loaded message. - */ - delete msg.rid; + msg._hidden = true; Messages.upsert({ _id }, msg); } }); @@ -600,7 +594,7 @@ const processSequentials = ({ currentNode, settings, forceDate, showDateSeparato } else { nextNode.classList.remove('new-day'); } - } else { + } else if (shouldCollapseReplies) { const [el] = $(`#chat-window-${ msg.rid }`); const view = el && Blaze.getView(el); const templateInstance = view && view.templateInstance(); diff --git a/app/ui-message/client/messageBox/messageBox.js b/app/ui-message/client/messageBox/messageBox.js index aebd9464543a..947c1d7b3679 100644 --- a/app/ui-message/client/messageBox/messageBox.js +++ b/app/ui-message/client/messageBox/messageBox.js @@ -181,7 +181,6 @@ Template.messageBox.helpers({ if (!rid) { return false; } - const isAnonymous = !Meteor.userId(); return isAnonymous || instance.state.get('mustJoinWithCode'); }, diff --git a/app/ui-message/client/messageBox/messageBoxNotSubscribed.js b/app/ui-message/client/messageBox/messageBoxNotSubscribed.js index 86e69e1203d5..75cb1b1c1f3c 100644 --- a/app/ui-message/client/messageBox/messageBoxNotSubscribed.js +++ b/app/ui-message/client/messageBox/messageBoxNotSubscribed.js @@ -2,7 +2,8 @@ import { Meteor } from 'meteor/meteor'; import { Session } from 'meteor/session'; import { Template } from 'meteor/templating'; import { settings } from '../../../settings'; -import { call, roomTypes, RoomManager, RoomHistoryManager } from '../../../ui-utils'; +import { call, RoomManager, RoomHistoryManager } from '../../../ui-utils'; +import { roomTypes } from '../../../utils'; import { hasAllPermission } from '../../../authorization'; import './messageBoxNotSubscribed.html'; diff --git a/app/ui-utils/client/lib/RoomHistoryManager.js b/app/ui-utils/client/lib/RoomHistoryManager.js index 9fe6fec72a75..c15da4b54aa1 100644 --- a/app/ui-utils/client/lib/RoomHistoryManager.js +++ b/app/ui-utils/client/lib/RoomHistoryManager.js @@ -102,7 +102,7 @@ export const RoomHistoryManager = new class { room.isLoading.set(true); // ScrollListener.setLoader true - const lastMessage = ChatMessage.findOne({ rid }, { sort: { ts: 1 } }); + const lastMessage = ChatMessage.findOne({ rid, _hidden: { $ne: true } }, { sort: { ts: 1 } }); // lastMessage ?= ChatMessage.findOne({rid: rid}, {sort: {ts: 1}}) if (lastMessage) { @@ -180,7 +180,7 @@ export const RoomHistoryManager = new class { room.isLoading.set(true); - const lastMessage = ChatMessage.findOne({ rid }, { sort: { ts: -1 } }); + const lastMessage = ChatMessage.findOne({ rid, _hidden: { $ne: true } }, { sort: { ts: -1 } }); let typeName = undefined; @@ -225,7 +225,7 @@ export const RoomHistoryManager = new class { const instance = Blaze.getView($('.messages-box .wrapper')[0]).templateInstance(); - if (ChatMessage.findOne(message._id)) { + if (ChatMessage.findOne({ _id: message._id, _hidden: { $ne: true } })) { const wrapper = $('.messages-box .wrapper'); const msgElement = $(`#${ message._id }`, wrapper); if (msgElement.length === 0) { diff --git a/app/ui-utils/client/lib/RoomManager.js b/app/ui-utils/client/lib/RoomManager.js index 45f9b15c6777..871362662825 100644 --- a/app/ui-utils/client/lib/RoomManager.js +++ b/app/ui-utils/client/lib/RoomManager.js @@ -258,7 +258,7 @@ export const RoomManager = new function() { }; const loadMissedMessages = function(rid) { - const lastMessage = ChatMessage.findOne({ rid, temp: { $exists: false } }, { sort: { ts: -1 }, limit: 1 }); + const lastMessage = ChatMessage.findOne({ rid, _hidden: { $ne: true }, temp: { $exists: false } }, { sort: { ts: -1 }, limit: 1 }); if (lastMessage == null) { return; } diff --git a/app/ui/client/views/app/room.js b/app/ui/client/views/app/room.js index 3e9527743cd1..36827a40551f 100644 --- a/app/ui/client/views/app/room.js +++ b/app/ui/client/views/app/room.js @@ -276,6 +276,7 @@ Template.room.helpers({ const viewMode = getUserPreference(Meteor.userId(), 'messageViewMode'); const query = { rid, + _hidden: { $ne: true }, ...((ignoreReplies || modes[viewMode] === 'compact') && { tmid: { $exists: 0 } }), }; @@ -596,13 +597,14 @@ Template.room.events({ event.preventDefault(); event.stopPropagation(); - const { tabBar } = Template.instance(); + const { tabBar, subscription } = Template.instance(); const { msg, msg: { rid, _id, tmid } } = messageArgs(this); const $flexTab = $('.flex-tab-container .flex-tab'); $flexTab.attr('template', 'thread'); tabBar.setData({ + subscription: subscription.get(), msg, rid, mid: tmid || _id,