Loading client/routes/router.coffee +0 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ BlazeLayout.setRoot 'body' FlowRouter.subscriptions = -> Tracker.autorun => if Meteor.userId() RoomManager.init() @register 'userData', Meteor.subscribe('userData') @register 'activeUsers', Meteor.subscribe('activeUsers') Loading packages/rocketchat-authorization/client/lib/ChatPermissions.coffee +1 −3 Original line number Diff line number Diff line RocketChat.authz.cachedCollection = new RocketChat.CachedCollection({ name: 'permissions', eventType: 'onAll' }) RocketChat.authz.cachedCollection = new RocketChat.CachedCollection({ name: 'permissions', eventType: 'onAll', initOnLogin: true }) @ChatPermissions = RocketChat.authz.cachedCollection.collection RocketChat.authz.cachedCollection.init() packages/rocketchat-lib/client/lib/cachedCollection.js +47 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,26 @@ class CachedCollectionManager { constructor() { this.items = []; this._syncEnabled = false; this.loginCb = []; this.logged = false; const _unstoreLoginToken = Accounts._unstoreLoginToken; Accounts._unstoreLoginToken = (...args) => { _unstoreLoginToken.apply(Accounts, args); this.clearAllCache(); this.clearAllCacheOnLogout(); }; Tracker.autorun(() => { if (Meteor.userId() !== null) { if (this.logged === false) { for (const cb of this.loginCb) { cb(); } } } this.logged = Meteor.userId() !== null; }); } register(cachedCollection) { Loading @@ -22,6 +36,12 @@ class CachedCollectionManager { } } clearAllCacheOnLogout() { for (const item of this.items) { item.clearCacheOnLogout(); } } countQueries() { for (const item of this.items) { item.countQueries(); Loading @@ -36,6 +56,13 @@ class CachedCollectionManager { get syncEnabled() { return this._syncEnabled; } onLogin(cb) { this.loginCb.push(cb); if (this.logged) { cb(); } } } RocketChat.CachedCollectionManager = new CachedCollectionManager; Loading @@ -49,6 +76,7 @@ class CachedCollection { syncMethodName, eventName, eventType = 'onUser', initOnLogin = false, useSync = true, useCache = true, debug = true, Loading @@ -67,10 +95,21 @@ class CachedCollection { this.useCache = useCache; this.debug = debug; this.version = version; this.initOnLogin = initOnLogin; this.updatedAt = new Date(0); this.maxCacheTime = maxCacheTime; RocketChat.CachedCollectionManager.register(this); if (initOnLogin === true) { RocketChat.CachedCollectionManager.onLogin(() => { this.log('Init on login'); this.ready.set(false); this.updatedAt = new Date(0); this.initiated = false; this.init(); }); } } log(...args) { Loading Loading @@ -209,9 +248,16 @@ class CachedCollection { this.log('saving cache (done)'); } clearCacheOnLogout() { if (this.initOnLogin === true) { this.clearCache(); } } clearCache() { this.log('clearing cache'); localforage.removeItem(this.name); this.collection.remove({}); } setupListener(eventType, eventName) { Loading packages/rocketchat-ui/lib/RoomManager.coffee +0 −9 Original line number Diff line number Diff line Loading @@ -55,14 +55,6 @@ Tracker.autorun -> Dep = new Tracker.Dependency init = -> if CachedChatSubscription.ready.get() return CachedChatSubscription.init() return close = (typeName) -> if openedRooms[typeName] if openedRooms[typeName].sub? Loading Loading @@ -245,7 +237,6 @@ Tracker.autorun -> open: open close: close closeAllRooms: closeAllRooms init: init getDomOfRoom: getDomOfRoom existsDomOfRoom: existsDomOfRoom msgStream: msgStream Loading packages/rocketchat-ui/lib/collections.coffee +1 −1 Original line number Diff line number Diff line @ChatMessage = new Meteor.Collection null @ChatRoom = new Meteor.Collection 'rocketchat_room' @CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions' }) @CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions', initOnLogin: true }) @ChatSubscription = CachedChatSubscription.collection @UserRoles = new Mongo.Collection null @RoomRoles = new Mongo.Collection null Loading Loading
client/routes/router.coffee +0 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ BlazeLayout.setRoot 'body' FlowRouter.subscriptions = -> Tracker.autorun => if Meteor.userId() RoomManager.init() @register 'userData', Meteor.subscribe('userData') @register 'activeUsers', Meteor.subscribe('activeUsers') Loading
packages/rocketchat-authorization/client/lib/ChatPermissions.coffee +1 −3 Original line number Diff line number Diff line RocketChat.authz.cachedCollection = new RocketChat.CachedCollection({ name: 'permissions', eventType: 'onAll' }) RocketChat.authz.cachedCollection = new RocketChat.CachedCollection({ name: 'permissions', eventType: 'onAll', initOnLogin: true }) @ChatPermissions = RocketChat.authz.cachedCollection.collection RocketChat.authz.cachedCollection.init()
packages/rocketchat-lib/client/lib/cachedCollection.js +47 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,26 @@ class CachedCollectionManager { constructor() { this.items = []; this._syncEnabled = false; this.loginCb = []; this.logged = false; const _unstoreLoginToken = Accounts._unstoreLoginToken; Accounts._unstoreLoginToken = (...args) => { _unstoreLoginToken.apply(Accounts, args); this.clearAllCache(); this.clearAllCacheOnLogout(); }; Tracker.autorun(() => { if (Meteor.userId() !== null) { if (this.logged === false) { for (const cb of this.loginCb) { cb(); } } } this.logged = Meteor.userId() !== null; }); } register(cachedCollection) { Loading @@ -22,6 +36,12 @@ class CachedCollectionManager { } } clearAllCacheOnLogout() { for (const item of this.items) { item.clearCacheOnLogout(); } } countQueries() { for (const item of this.items) { item.countQueries(); Loading @@ -36,6 +56,13 @@ class CachedCollectionManager { get syncEnabled() { return this._syncEnabled; } onLogin(cb) { this.loginCb.push(cb); if (this.logged) { cb(); } } } RocketChat.CachedCollectionManager = new CachedCollectionManager; Loading @@ -49,6 +76,7 @@ class CachedCollection { syncMethodName, eventName, eventType = 'onUser', initOnLogin = false, useSync = true, useCache = true, debug = true, Loading @@ -67,10 +95,21 @@ class CachedCollection { this.useCache = useCache; this.debug = debug; this.version = version; this.initOnLogin = initOnLogin; this.updatedAt = new Date(0); this.maxCacheTime = maxCacheTime; RocketChat.CachedCollectionManager.register(this); if (initOnLogin === true) { RocketChat.CachedCollectionManager.onLogin(() => { this.log('Init on login'); this.ready.set(false); this.updatedAt = new Date(0); this.initiated = false; this.init(); }); } } log(...args) { Loading Loading @@ -209,9 +248,16 @@ class CachedCollection { this.log('saving cache (done)'); } clearCacheOnLogout() { if (this.initOnLogin === true) { this.clearCache(); } } clearCache() { this.log('clearing cache'); localforage.removeItem(this.name); this.collection.remove({}); } setupListener(eventType, eventName) { Loading
packages/rocketchat-ui/lib/RoomManager.coffee +0 −9 Original line number Diff line number Diff line Loading @@ -55,14 +55,6 @@ Tracker.autorun -> Dep = new Tracker.Dependency init = -> if CachedChatSubscription.ready.get() return CachedChatSubscription.init() return close = (typeName) -> if openedRooms[typeName] if openedRooms[typeName].sub? Loading Loading @@ -245,7 +237,6 @@ Tracker.autorun -> open: open close: close closeAllRooms: closeAllRooms init: init getDomOfRoom: getDomOfRoom existsDomOfRoom: existsDomOfRoom msgStream: msgStream Loading
packages/rocketchat-ui/lib/collections.coffee +1 −1 Original line number Diff line number Diff line @ChatMessage = new Meteor.Collection null @ChatRoom = new Meteor.Collection 'rocketchat_room' @CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions' }) @CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions', initOnLogin: true }) @ChatSubscription = CachedChatSubscription.collection @UserRoles = new Mongo.Collection null @RoomRoles = new Mongo.Collection null Loading