diff --git a/app/ui/client/views/app/room.js b/app/ui/client/views/app/room.js
index ece88045b661b..36a0ff3d495d3 100644
--- a/app/ui/client/views/app/room.js
+++ b/app/ui/client/views/app/room.js
@@ -269,7 +269,7 @@ Template.roomOld.helpers({
},
messageboxData() {
- const { sendToBottomIfNecessaryDebounced, subscription } = Template.instance();
+ const { sendToBottomIfNecessary, subscription } = Template.instance();
const { _id: rid } = this;
const isEmbedded = Layout.isEmbedded();
const showFormattingTips = settings.get('Message_ShowFormattingTips');
@@ -286,7 +286,7 @@ Template.roomOld.helpers({
chatMessages[rid].initializeInput(input, { rid });
},
- onResize: () => sendToBottomIfNecessaryDebounced && sendToBottomIfNecessaryDebounced(),
+ onResize: () => sendToBottomIfNecessary && sendToBottomIfNecessary(),
onKeyUp: (...args) => chatMessages[rid] && chatMessages[rid].keyup.apply(chatMessages[rid], args),
onKeyDown: (...args) => chatMessages[rid] && chatMessages[rid].keydown.apply(chatMessages[rid], args),
onSend: (...args) => chatMessages[rid] && chatMessages[rid].send.apply(chatMessages[rid], args),
@@ -432,9 +432,6 @@ Template.roomOld.helpers({
},
});
-let lastScrollTop;
-
-
export const dropzoneEvents = {
'dragenter .dropzone'(e) {
const types = e.originalEvent && e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.types;
@@ -552,15 +549,15 @@ Meteor.startup(() => {
RoomHistoryManager.clear(template && template.data && template.data._id);
},
'load .gallery-item'(e, template) {
- template.sendToBottomIfNecessaryDebounced();
+ template.sendToBottomIfNecessary();
},
'rendered .js-block-wrapper'(e, template) {
- template.sendToBottomIfNecessaryDebounced();
+ template.sendToBottomIfNecessary();
},
'click .new-message'(event, instance) {
instance.atBottom = true;
- instance.sendToBottomIfNecessaryDebounced();
+ instance.sendToBottomIfNecessary();
chatMessages[RoomManager.openedRoom].input.focus();
},
'click .upload-progress-close'(e) {
@@ -584,26 +581,26 @@ Meteor.startup(() => {
'scroll .wrapper': _.throttle(function(e, t) {
const $roomLeader = $('.room-leader');
if ($roomLeader.length) {
- if (e.target.scrollTop < lastScrollTop) {
+ if (e.target.scrollTop < t.lastScrollTop) {
t.hideLeaderHeader.set(false);
} else if (t.isAtBottom(100) === false && e.target.scrollTop > $roomLeader.height()) {
t.hideLeaderHeader.set(true);
}
}
- lastScrollTop = e.target.scrollTop;
+ t.lastScrollTop = e.target.scrollTop;
const height = e.target.clientHeight;
const isLoading = RoomHistoryManager.isLoading(this._id);
const hasMore = RoomHistoryManager.hasMore(this._id);
const hasMoreNext = RoomHistoryManager.hasMoreNext(this._id);
if ((isLoading === false && hasMore === true) || hasMoreNext === true) {
- if (hasMore === true && lastScrollTop <= height / 3) {
+ if (hasMore === true && t.lastScrollTop <= height / 3) {
RoomHistoryManager.getMore(this._id);
- } else if (hasMoreNext === true && Math.ceil(lastScrollTop) >= e.target.scrollHeight - height) {
+ } else if (hasMoreNext === true && Math.ceil(t.lastScrollTop) >= e.target.scrollHeight - height) {
RoomHistoryManager.getMoreNext(this._id);
}
}
- }, 300),
+ }, 100),
'click .time a'(e) {
e.preventDefault();
@@ -765,8 +762,6 @@ Meteor.startup(() => {
this.sendToBottom();
}
};
-
- this.sendToBottomIfNecessaryDebounced = _.debounce(this.sendToBottomIfNecessary, 10);
}); // Update message to re-render DOM
Template.roomOld.onDestroyed(function() {
@@ -812,7 +807,7 @@ Meteor.startup(() => {
};
template.sendToBottom = function() {
- wrapper.scrollTop = wrapper.scrollHeight - wrapper.clientHeight;
+ wrapper.scrollTo(30, wrapper.scrollHeight);
newMessage.className = 'new-message background-primary-action-color color-content-background-color not';
};
@@ -820,22 +815,14 @@ Meteor.startup(() => {
template.atBottom = template.isAtBottom(100);
};
+ template.observer = new ResizeObserver(() => template.sendToBottomIfNecessary());
- if (window.MutationObserver) {
- template.observer = new MutationObserver(() => template.sendToBottomIfNecessaryDebounced());
-
- template.observer.observe(wrapperUl, { childList: true });
- } else {
- wrapperUl.addEventListener('DOMSubtreeModified', () => template.sendToBottomIfNecessaryDebounced());
- }
-
- template.onWindowResize = () => template.sendToBottomIfNecessaryDebounced();
-
- window.addEventListener('resize', template.onWindowResize);
+ template.observer.observe(wrapperUl);
const wheelHandler = _.throttle(function() {
template.checkIfScrollIsAtBottom();
}, 100);
+
wrapper.addEventListener('mousewheel', wheelHandler);
wrapper.addEventListener('wheel', wheelHandler);
@@ -853,7 +840,7 @@ Meteor.startup(() => {
wrapper.addEventListener('scroll', wheelHandler);
});
- lastScrollTop = $('.messages-box .wrapper').scrollTop();
+ this.lastScrollTop = $('.messages-box .wrapper').scrollTop();
const rtl = $('html').hasClass('rtl');
@@ -983,9 +970,6 @@ Meteor.startup(() => {
return FlowRouter.go('home');
}
});
-
- const observer = new ResizeObserver(template.sendToBottomIfNecessary);
- observer.observe(this.firstNode.querySelector('.wrapper ul'));
});
});
diff --git a/client/views/room/contextualBar/RoomMembers/InviteUsers/InviteUsers.js b/client/views/room/contextualBar/RoomMembers/InviteUsers/InviteUsers.js
index d2b3924550d18..9576badf63ca7 100644
--- a/client/views/room/contextualBar/RoomMembers/InviteUsers/InviteUsers.js
+++ b/client/views/room/contextualBar/RoomMembers/InviteUsers/InviteUsers.js
@@ -30,7 +30,7 @@ export const InviteUsers = ({
{onClickClose && }
-
+
{t('Invite_Link')}
@@ -45,7 +45,7 @@ export const InviteUsers = ({
{onClickEdit && }
-
+
);
};