From e6e3e35b5bc733dfca024c6923113556f3026dfc Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Mon, 22 Feb 2021 11:26:41 -0300 Subject: [PATCH] Prevent Message Attachment reredering --- app/ui-utils/client/lib/Layout.js | 5 ++++- app/ui-utils/client/lib/messageContext.js | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/ui-utils/client/lib/Layout.js b/app/ui-utils/client/lib/Layout.js index 758f58a99fa7..2158d80f2a9b 100644 --- a/app/ui-utils/client/lib/Layout.js +++ b/app/ui-utils/client/lib/Layout.js @@ -1,14 +1,17 @@ import { Tracker } from 'meteor/tracker'; import { FlowRouter } from 'meteor/kadira:flow-router'; +import { ReactiveVar } from 'meteor/reactive-var'; export const Layout = new class RocketChatLayout { constructor() { + this.embedded = new ReactiveVar(); Tracker.autorun(() => { this.layout = FlowRouter.getQueryParam('layout'); + this.embedded.set(this.layout === 'embedded'); }); } isEmbedded() { - return FlowRouter.getQueryParam('layout') === 'embedded'; + return this.embedded.get(); } }(); diff --git a/app/ui-utils/client/lib/messageContext.js b/app/ui-utils/client/lib/messageContext.js index d10e7cd8ccbf..283cddf5bb9e 100644 --- a/app/ui-utils/client/lib/messageContext.js +++ b/app/ui-utils/client/lib/messageContext.js @@ -1,6 +1,7 @@ import { Meteor } from 'meteor/meteor'; import { Template } from 'meteor/templating'; import { FlowRouter } from 'meteor/kadira:flow-router'; +import { Tracker } from 'meteor/tracker'; import { Subscriptions, Rooms, Users } from '../../../models/client'; import { hasPermission } from '../../../authorization/client'; @@ -17,7 +18,7 @@ const fields = { name: 1, username: 1, 'settings.preferences.showMessageInMainTh export function messageContext({ rid } = Template.instance()) { const uid = Meteor.userId(); const user = Users.findOne({ _id: uid }, { fields }) || {}; - const instace = Template.instance(); + const instance = Template.instance(); const openThread = (e) => { const { rid, mid, tmid } = e.currentTarget.dataset; const room = Rooms.findOne({ _id: rid }); @@ -40,7 +41,7 @@ export function messageContext({ rid } = Template.instance()) { }); } : (msg, e) => { const { actionlink } = e.currentTarget.dataset; - actionLinks.run(actionlink, msg._id, instace, (err) => { + actionLinks.run(actionlink, msg._id, instance, (err) => { if (err) { handleError(err); } @@ -60,13 +61,12 @@ export function messageContext({ rid } = Template.instance()) { return { u: user, - room: Rooms.findOne({ _id: rid }, { - reactive: false, + room: Tracker.nonreactive(() => Rooms.findOne({ _id: rid }, { fields: { _updatedAt: 0, lastMessage: 0, }, - }), + })), subscription: Subscriptions.findOne({ rid }, { fields: { name: 1,