The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/app/threads/client/flextab/threads.js

168 lines
4.7 KiB

[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
import { Mongo } from 'meteor/mongo';
import { Tracker } from 'meteor/tracker';
import { Template } from 'meteor/templating';
import { ReactiveDict } from 'meteor/reactive-dict';
import _ from 'underscore';
import { lazyloadtick } from '../../../lazy-load';
import { call } from '../../../ui-utils';
import { Messages, Subscriptions } from '../../../models';
import { messageContext } from '../../../ui-utils/client/lib/messageContext';
import { messageArgs } from '../../../ui-utils/client/lib/messageArgs';
import { upsert } from '../upsert';
import './threads.html';
const LIST_SIZE = 50;
const sort = { tlm: -1 };
Template.threads.events({
'click .js-open-thread'(e, instance) {
const { msg } = messageArgs(this);
instance.state.set('mid', msg._id);
e.preventDefault();
e.stopPropagation();
return false;
},
'scroll .js-scroll-threads': _.throttle(({ currentTarget: e }, { incLimit }) => {
lazyloadtick();
if (e.offsetHeight + e.scrollTop <= e.scrollHeight - 50) {
incLimit && incLimit();
}
}, 500),
});
Template.threads.helpers({
doDotLoadThreads() {
return Template.instance().state.get('close');
},
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
close() {
const { state, data } = Template.instance();
const { tabBar } = data;
return () => (state.get('close') ? tabBar.close() : state.set('mid', null));
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
},
message() {
return Template.instance().state.get('thread');
},
isLoading() {
return Template.instance().state.get('loading');
},
hasNoThreads() {
return !Template.instance().state.get('loading') && Template.instance().Threads.find({ rid: Template.instance().state.get('rid') }, { sort }).count() === 0;
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
},
threads() {
return Template.instance().Threads.find({ rid: Template.instance().state.get('rid') }, { sort, limit: Template.instance().state.get('limit') });
},
messageContext,
});
Template.threads.onCreated(async function() {
this.Threads = new Mongo.Collection(null);
const { rid, mid, msg } = this.data;
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
this.state = new ReactiveDict({
rid,
close: !!mid,
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
loading: true,
mid,
thread: msg,
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
});
this.incLimit = () => {
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
const { rid, limit } = Tracker.nonreactive(() => this.state.all());
const count = this.Threads.find({ rid }).count();
if (limit > count) {
return;
}
this.state.set('limit', this.state.get('limit') + LIST_SIZE);
this.loadMore();
};
this.loadMore = _.debounce(async () => {
const { rid, limit } = Tracker.nonreactive(() => this.state.all());
if (this.state.get('loading') === rid) {
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
return;
}
this.state.set('loading', rid);
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
const threads = await call('getThreadsList', { rid, limit: LIST_SIZE, skip: limit - LIST_SIZE });
upsert(this.Threads, threads);
// threads.forEach(({ _id, ...msg }) => this.Threads.upsert({ _id }, msg));
this.state.set('loading', false);
}, 500);
Tracker.afterFlush(() => {
this.autorun(async () => {
const { rid, mid } = Template.currentData();
this.state.set({
close: !!mid,
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
mid,
rid,
});
});
});
this.autorun(() => {
const rid = this.state.get('rid');
this.rid = rid;
this.state.set({
limit: LIST_SIZE,
});
this.loadMore();
});
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({
[NEW] Threads V 1.0 (#13996) * first commit * empty reply method * permissions and settings * hooks * canSendMessage server function * follow unfollow methods * message tmid index * removed useless permissons * Notification and Hooks * remove edit-room-title * flextab threads and thread view * improved message render * open threads on click * group message * Save unread threads on subscription * group thread messages * useless css * follow unfollow methods * Fix unread threads * follow unfollow actions and badge on flextab * unread button * fix multiple getThreadMessages * Add notifications * Move thread queries to models * Move lib file to server folder * Fix notifications for users in thread * small changes * Remove stub thread reply * Normalize thread files * message template * Fix notification on first reply * Fix follow/unfollow * Fix removing a thread on last message delete * fix open flextab * getmessages instead getSinglemessage * Fix remove thread message * Fix delete thread * fix open multiple threads * Fix removing threads * Add more tests to todo * fix * fix * icons and i18n * Fix thread title on replies * Fix async * onViewRendered * fix reactions and removed css code * fix blaze variable * threads tab order * thread replies button * i18n * fix test * fix tests and css * removed limits to thread list * fix grouping time * fix load message * style changes * fix unread badge * fix role description * clear read thread * ajust badge * time ago threads * jump to messages * mention link * tick mention * fix reloading threadlist after reply * Pass rid and showFormattingTips as parameters to messageBox template * Remove references to RoomManager in messageBox template * Remove some invalid references * Remove some invalid references * Reduce messageBox coupling * Add small fixes * Extract more parameters from messageBox * Fix emoji picker button * Remove all references to chatMessages in messageBox * Change focus handling * Refactor autogrow plugin * Fix calling modal.open() on modal confirm callback * Disable message reply action for same user * Refactor ChatMessages * Pass rid to messagePopupConfig * Fix attachment description update * Move RTL change logic to messageBox * Pass rid to fileUpload helper * Don't use openedRoom session variable in room template * Add tmid support * Rename mountReply helper as prependReplies * scroll at bottom thread * Simplify messageBox events * Refactor ChatMessages.send * Fix messagePopupConfig for emojis * Split chatMessages initialization * Revert "Disable message reply action for same user" This reverts commit f9dc0b486e8fe8aa52012fa6e21bc4961ad5d674. * Set outline style for open thread buttons * Test atBottom condition on thread template before request scroll * Update join button * Protect messageBox from rid absence * Embed messageBox into thread template * Wait thread update before request scroll * Increase font-weight for rc-button
6 years ago
added: ({ _id, ...message }) => {
this.Threads.upsert({ _id }, message);
}, // Update message to re-render DOM
changed: ({ _id, ...message }) => {
this.Threads.update({ _id }, message);
}, // Update message to re-render DOM
removed: ({ _id }) => {
this.Threads.remove(_id);
const { _id: mid } = this.mid.get() || {};
if (_id === mid) {
this.mid.set(null);
}
},
});
const alert = 'Unread';
this.subscriptionObserve && this.subscriptionObserve.stop();
this.subscriptionObserve = Subscriptions.find({ rid }, { fields: { tunread: 1 } }).observeChanges({
added: (_id, { tunread }) => {
tunread && tunread.length && this.Threads.update({ tmid: { $in: tunread } }, { $set: { alert } }, { multi: true });
},
changed: (id, { tunread = [] }) => {
this.Threads.update({ alert, _id: { $nin: tunread } }, { $unset: { alert: 1 } }, { multi: true });
tunread && tunread.length && this.Threads.update({ _id: { $in: tunread } }, { $set: { alert } }, { multi: true });
},
});
});
this.autorun(async () => {
const mid = this.state.get('mid');
return this.state.set('thread', mid && this.Threads.findOne({ _id: mid }, { fields: { tcount: 0, tlm: 0, replies: 0, _updatedAt: 0 } }));
});
});
Template.threads.onDestroyed(function() {
const { Threads, threadsObserve, subscriptionObserve } = this;
Threads.remove({});
threadsObserve && threadsObserve.stop();
subscriptionObserve && subscriptionObserve.stop();
});