diff --git a/packages/rocketchat-api/server/v1/users.js b/packages/rocketchat-api/server/v1/users.js
index bb65480c98495..4968333125577 100644
--- a/packages/rocketchat-api/server/v1/users.js
+++ b/packages/rocketchat-api/server/v1/users.js
@@ -327,7 +327,6 @@ RocketChat.API.v1.addRoute('users.setPreferences', { authRequired: true }, {
collapseMediaByDefault: Match.Maybe(Boolean),
autoImageLoad: Match.Maybe(Boolean),
emailNotificationMode: Match.Maybe(String),
- roomsListExhibitionMode: Match.Maybe(String),
unreadAlert: Match.Maybe(Boolean),
notificationsSoundVolume: Match.Maybe(Number),
desktopNotifications: Match.Maybe(String),
@@ -348,7 +347,7 @@ RocketChat.API.v1.addRoute('users.setPreferences', { authRequired: true }, {
sidebarSortby: Match.Optional(String),
sidebarViewMode: Match.Optional(String),
sidebarHideAvatar: Match.Optional(Boolean),
- groupByType: Match.Optional(Boolean),
+ sidebarGroupByType: Match.Optional(Boolean),
muteFocusedConversations: Match.Optional(Boolean)
})
});
diff --git a/packages/rocketchat-authorization/client/lib/models/Users.js b/packages/rocketchat-authorization/client/lib/models/Users.js
index 627d97ef7e834..e3af3062fb456 100644
--- a/packages/rocketchat-authorization/client/lib/models/Users.js
+++ b/packages/rocketchat-authorization/client/lib/models/Users.js
@@ -11,7 +11,7 @@ Object.assign(RocketChat.models.Users, {
roles: roleName
};
- return !_.isUndefined(this.findOne(query));
+ return !_.isUndefined(this.findOne(query, {fields: {roles: 1}}));
},
findUsersInRoles(roles, scope, options) {
diff --git a/packages/rocketchat-authorization/server/models/Base.js b/packages/rocketchat-authorization/server/models/Base.js
index ea2da8071f271..9aa8fc1d30c91 100644
--- a/packages/rocketchat-authorization/server/models/Base.js
+++ b/packages/rocketchat-authorization/server/models/Base.js
@@ -17,7 +17,7 @@ RocketChat.models._Base.prototype.isUserInRole = function(userId, roleName, scop
}
query.roles = roleName;
- return !_.isUndefined(this.findOne(query));
+ return !_.isUndefined(this.findOne(query, {fields: {roles: 1}}));
};
RocketChat.models._Base.prototype.addRolesByUserId = function(userId, roles, scope) {
diff --git a/packages/rocketchat-lib/client/lib/cachedCollection.js b/packages/rocketchat-lib/client/lib/cachedCollection.js
index ddeaa28880814..1c04e3aaf1980 100644
--- a/packages/rocketchat-lib/client/lib/cachedCollection.js
+++ b/packages/rocketchat-lib/client/lib/cachedCollection.js
@@ -86,6 +86,13 @@ class CachedCollectionManager {
RocketChat.CachedCollectionManager = new CachedCollectionManager;
+const debug = false;
+
+const nullLog = function() {};
+
+const log = function(...args) {
+ console.log(`CachedCollection ${ this.name } =>`, ...args);
+};
class CachedCollection {
constructor({
@@ -98,7 +105,6 @@ class CachedCollection {
userRelated = true,
useSync = true,
useCache = true,
- debug = false,
version = 7,
maxCacheTime = 60*60*24*30,
onSyncData = (/* action, record */) => {}
@@ -119,7 +125,7 @@ class CachedCollection {
this.updatedAt = new Date(0);
this.maxCacheTime = maxCacheTime;
this.onSyncData = onSyncData;
-
+ this.log = debug ? log : nullLog;
RocketChat.CachedCollectionManager.register(this);
if (userRelated === true) {
@@ -137,12 +143,6 @@ class CachedCollection {
}
}
- log(...args) {
- if (this.debug === true) {
- console.log(`CachedCollection ${ this.name } =>`, ...args);
- }
- }
-
countQueries() {
this.log(`${ Object.keys(this.collection._collection.queries).length } queries`);
}
@@ -184,6 +184,7 @@ class CachedCollection {
if (data && data.records && data.records.length > 0) {
this.log(`${ data.records.length } records loaded from cache`);
data.records.forEach((record) => {
+ RocketChat.callbacks.run(`cachedCollection-loadFromCache-${ this.name }`, record);
record.__cache__ = true;
this.collection.upsert({ _id: record._id }, _.omit(record, '_id'));
@@ -207,6 +208,7 @@ class CachedCollection {
this.log(`${ data.length } records loaded from server`);
data.forEach((record) => {
delete record.$loki;
+ RocketChat.callbacks.run(`cachedCollection-loadFromServer-${ this.name }`, record, 'changed');
this.collection.upsert({ _id: record._id }, _.omit(record, '_id'));
this.onSyncData('changed', record);
@@ -269,7 +271,7 @@ class CachedCollection {
for (const record of changes) {
delete record.$loki;
-
+ RocketChat.callbacks.run(`cachedCollection-sync-${ this.name }`, record, record._deletedAt? 'removed' : 'changed');
if (record._deletedAt) {
this.collection.remove({ _id: record._id });
@@ -329,6 +331,7 @@ class CachedCollection {
setupListener(eventType, eventName) {
RocketChat.Notifications[eventType || this.eventType](eventName || this.eventName, (t, record) => {
this.log('record received', t, record);
+ RocketChat.callbacks.run(`cachedCollection-received-${ this.name }`, record, t);
if (t === 'removed') {
this.collection.remove(record._id);
RoomManager.close(record.t+record.name);
diff --git a/packages/rocketchat-lib/lib/getUserPreference.js b/packages/rocketchat-lib/lib/getUserPreference.js
index 1d516996784de..3e07d76bf5b88 100644
--- a/packages/rocketchat-lib/lib/getUserPreference.js
+++ b/packages/rocketchat-lib/lib/getUserPreference.js
@@ -4,7 +4,9 @@
*/
RocketChat.getUserPreference = function(user, key, defaultValue=undefined) {
let preference;
-
+ if (typeof user === typeof '') {
+ user = RocketChat.models.Users.findOne(user, {fields: {[`settings.preferences.${ key }`]: 1}});
+ }
if (user && user.settings && user.settings.preferences &&
user.settings.preferences.hasOwnProperty(key)) {
preference = user.settings.preferences[key];
diff --git a/packages/rocketchat-lib/lib/roomTypes/conversation.js b/packages/rocketchat-lib/lib/roomTypes/conversation.js
index 9a0f9eb51d8fa..a82886619ef47 100644
--- a/packages/rocketchat-lib/lib/roomTypes/conversation.js
+++ b/packages/rocketchat-lib/lib/roomTypes/conversation.js
@@ -10,8 +10,7 @@ export class ConversationRoomType extends RoomTypeConfig {
}
condition() {
- const user = Meteor.user();
- // returns true only if groupByType is not set
- return !RocketChat.getUserPreference(user, 'groupByType');
+ // returns true only if sidebarGroupByType is not set
+ return !RocketChat.getUserPreference(Meteor.userId(), 'sidebarGroupByType');
}
}
diff --git a/packages/rocketchat-lib/lib/roomTypes/direct.js b/packages/rocketchat-lib/lib/roomTypes/direct.js
index 0e32b7587d257..f1ba44c1cd02d 100644
--- a/packages/rocketchat-lib/lib/roomTypes/direct.js
+++ b/packages/rocketchat-lib/lib/roomTypes/direct.js
@@ -61,8 +61,7 @@ export class DirectMessageRoomType extends RoomTypeConfig {
}
condition() {
- const user = Meteor.user();
- const groupByType = RocketChat.getUserPreference(user, 'groupByType');
+ const groupByType = RocketChat.getUserPreference(Meteor.userId(), 'sidebarGroupByType');
return groupByType && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']);
}
diff --git a/packages/rocketchat-lib/lib/roomTypes/favorite.js b/packages/rocketchat-lib/lib/roomTypes/favorite.js
index 2b927c0767ad5..c40fd91a5aebe 100644
--- a/packages/rocketchat-lib/lib/roomTypes/favorite.js
+++ b/packages/rocketchat-lib/lib/roomTypes/favorite.js
@@ -11,7 +11,6 @@ export class FavoriteRoomType extends RoomTypeConfig {
});
}
condition() {
- const user = Meteor.user();
- return RocketChat.settings.get('Favorite_Rooms') && RocketChat.getUserPreference(user, 'sidebarShowFavorites');
+ return RocketChat.settings.get('Favorite_Rooms') && RocketChat.getUserPreference(Meteor.userId(), 'sidebarShowFavorites');
}
}
diff --git a/packages/rocketchat-lib/lib/roomTypes/private.js b/packages/rocketchat-lib/lib/roomTypes/private.js
index fd95a7cec737f..b32b1032f3443 100644
--- a/packages/rocketchat-lib/lib/roomTypes/private.js
+++ b/packages/rocketchat-lib/lib/roomTypes/private.js
@@ -43,8 +43,7 @@ export class PrivateRoomType extends RoomTypeConfig {
}
condition() {
- const user = Meteor.user();
- const groupByType = RocketChat.getUserPreference(user, 'groupByType');
+ const groupByType = RocketChat.getUserPreference(Meteor.userId(), 'sidebarGroupByType');
return groupByType && RocketChat.authz.hasAllPermission('view-p-room');
}
diff --git a/packages/rocketchat-lib/lib/roomTypes/public.js b/packages/rocketchat-lib/lib/roomTypes/public.js
index ced1a930b8ad6..ce022408c2da6 100644
--- a/packages/rocketchat-lib/lib/roomTypes/public.js
+++ b/packages/rocketchat-lib/lib/roomTypes/public.js
@@ -41,9 +41,7 @@ export class PublicRoomType extends RoomTypeConfig {
}
condition() {
- const user = Meteor.user();
- // const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode');
- const groupByType = RocketChat.getUserPreference(user, 'groupByType');
+ const groupByType = RocketChat.getUserPreference(Meteor.userId(), 'sidebarGroupByType');
return groupByType && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true);
}
diff --git a/packages/rocketchat-lib/lib/roomTypes/unread.js b/packages/rocketchat-lib/lib/roomTypes/unread.js
index 0e15cf0aa6fa3..4e18d40f3751c 100644
--- a/packages/rocketchat-lib/lib/roomTypes/unread.js
+++ b/packages/rocketchat-lib/lib/roomTypes/unread.js
@@ -12,7 +12,6 @@ export class UnreadRoomType extends RoomTypeConfig {
}
condition() {
- const user = Meteor.user();
- return RocketChat.getUserPreference(user, 'sidebarShowUnread');
+ return RocketChat.getUserPreference(Meteor.userId(), 'sidebarShowUnread');
}
}
diff --git a/packages/rocketchat-lib/server/startup/settings.js b/packages/rocketchat-lib/server/startup/settings.js
index 2ad5cc06fc18f..21921d092659f 100644
--- a/packages/rocketchat-lib/server/startup/settings.js
+++ b/packages/rocketchat-lib/server/startup/settings.js
@@ -299,24 +299,10 @@ RocketChat.settings.addGroup('Accounts', function() {
'public': true,
i18nLabel: 'Hide_Avatars'
});
- this.add('Accounts_Default_User_Preferences_roomsListExhibitionMode', 'category', {
- type: 'select',
- values: [
- {
- key: 'unread',
- i18nLabel: 'Unread_Rooms_Mode'
- },
- {
- key: 'activity',
- i18nLabel: 'Sort_by_activity'
- },
- {
- key: 'category',
- i18nLabel: 'Split_by_categories'
- }
- ],
+ this.add('Accounts_Default_User_Preferences_sidebarGroupByType', true, {
+ type: 'boolean',
'public': true,
- i18nLabel: 'Sidebar_list_mode'
+ i18nLabel: 'Group_by_Type'
});
this.add('Accounts_Default_User_Preferences_sidebarViewMode', 'medium', {
type: 'select',
diff --git a/packages/rocketchat-livechat/.app/package-lock.json b/packages/rocketchat-livechat/.app/package-lock.json
new file mode 100644
index 0000000000000..681cfcb10d6e0
--- /dev/null
+++ b/packages/rocketchat-livechat/.app/package-lock.json
@@ -0,0 +1,568 @@
+{
+ "name": "rocketchat-livechat",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "@babel/runtime": {
+ "version": "7.0.0-beta.46",
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0-beta.46.tgz",
+ "integrity": "sha512-/3a3USMKk54BEHhDgY8rtxtaQOs4bp4aQwo6SDtdwmrXmgSgEusWuXNX5oIs/nwzmTD9o8wz2EyAjA+uHDMmJA==",
+ "requires": {
+ "core-js": "2.5.5",
+ "regenerator-runtime": "0.11.1"
+ }
+ },
+ "autolinker": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/autolinker/-/autolinker-1.6.2.tgz",
+ "integrity": "sha512-IKLGtYFb3jzGTtgCpb4bm//1sXmmmgmr0msKshhYoc7EsWmLCFvuyxLcEIfcZ5gbCgZGXrnXkOkcBblOFEnlog=="
+ },
+ "bcrypt": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-2.0.1.tgz",
+ "integrity": "sha512-DwB7WgJPdskbR+9Y3OTJtwRq09Lmm7Na6b+4ewvXjkD0nfNRi1OozxljHm5ETlDCBq9DTy04lQz+rj+T2ztIJg==",
+ "requires": {
+ "nan": "2.10.0",
+ "node-pre-gyp": "0.9.1"
+ },
+ "dependencies": {
+ "abbrev": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
+ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
+ },
+ "ansi-regex": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
+ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
+ },
+ "aproba": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
+ "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw=="
+ },
+ "are-we-there-yet": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz",
+ "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=",
+ "requires": {
+ "delegates": "1.0.0",
+ "readable-stream": "2.3.5"
+ }
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
+ },
+ "brace-expansion": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "requires": {
+ "balanced-match": "1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "chownr": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz",
+ "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE="
+ },
+ "code-point-at": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
+ },
+ "console-control-strings": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
+ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
+ },
+ "debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "deep-extend": {
+ "version": "0.4.2",
+ "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz",
+ "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8="
+ },
+ "delegates": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
+ "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o="
+ },
+ "detect-libc": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
+ "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
+ },
+ "fs-minipass": {
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz",
+ "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==",
+ "requires": {
+ "minipass": "2.2.4"
+ }
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
+ },
+ "gauge": {
+ "version": "2.7.4",
+ "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",
+ "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
+ "requires": {
+ "aproba": "1.2.0",
+ "console-control-strings": "1.1.0",
+ "has-unicode": "2.0.1",
+ "object-assign": "4.1.1",
+ "signal-exit": "3.0.2",
+ "string-width": "1.0.2",
+ "strip-ansi": "3.0.1",
+ "wide-align": "1.1.2"
+ }
+ },
+ "glob": {
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
+ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
+ "requires": {
+ "fs.realpath": "1.0.0",
+ "inflight": "1.0.6",
+ "inherits": "2.0.3",
+ "minimatch": "3.0.4",
+ "once": "1.4.0",
+ "path-is-absolute": "1.0.1"
+ }
+ },
+ "has-unicode": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
+ "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk="
+ },
+ "iconv-lite": {
+ "version": "0.4.21",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.21.tgz",
+ "integrity": "sha512-En5V9za5mBt2oUA03WGD3TwDv0MKAruqsuxstbMUZaj9W9k/m1CV/9py3l0L5kw9Bln8fdHQmzHSYtvpvTLpKw==",
+ "requires": {
+ "safer-buffer": "2.1.2"
+ }
+ },
+ "ignore-walk": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz",
+ "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==",
+ "requires": {
+ "minimatch": "3.0.4"
+ }
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "requires": {
+ "once": "1.4.0",
+ "wrappy": "1.0.2"
+ }
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
+ },
+ "ini": {
+ "version": "1.3.5",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
+ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
+ },
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
+ "requires": {
+ "number-is-nan": "1.0.1"
+ }
+ },
+ "isarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
+ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "requires": {
+ "brace-expansion": "1.1.11"
+ }
+ },
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
+ },
+ "minipass": {
+ "version": "2.2.4",
+ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz",
+ "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
+ "requires": {
+ "safe-buffer": "5.1.1",
+ "yallist": "3.0.2"
+ },
+ "dependencies": {
+ "yallist": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
+ "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
+ }
+ }
+ },
+ "minizlib": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz",
+ "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==",
+ "requires": {
+ "minipass": "2.2.4"
+ }
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "requires": {
+ "minimist": "0.0.8"
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ },
+ "needle": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/needle/-/needle-2.2.0.tgz",
+ "integrity": "sha512-eFagy6c+TYayorXw/qtAdSvaUpEbBsDwDyxYFgLZ0lTojfH7K+OdBqAF7TAFwDokJaGpubpSGG0wO3iC0XPi8w==",
+ "requires": {
+ "debug": "2.6.9",
+ "iconv-lite": "0.4.21",
+ "sax": "1.2.4"
+ }
+ },
+ "node-pre-gyp": {
+ "version": "0.9.1",
+ "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.9.1.tgz",
+ "integrity": "sha1-8RwHUW3ZL4cZnbx+GDjqt81WyeA=",
+ "requires": {
+ "detect-libc": "1.0.3",
+ "mkdirp": "0.5.1",
+ "needle": "2.2.0",
+ "nopt": "4.0.1",
+ "npm-packlist": "1.1.10",
+ "npmlog": "4.1.2",
+ "rc": "1.2.6",
+ "rimraf": "2.6.2",
+ "semver": "5.5.0",
+ "tar": "4.4.1"
+ }
+ },
+ "nopt": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
+ "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=",
+ "requires": {
+ "abbrev": "1.1.1",
+ "osenv": "0.1.5"
+ }
+ },
+ "npm-bundled": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.3.tgz",
+ "integrity": "sha512-ByQ3oJ/5ETLyglU2+8dBObvhfWXX8dtPZDMePCahptliFX2iIuhyEszyFk401PZUNQH20vvdW5MLjJxkwU80Ow=="
+ },
+ "npm-packlist": {
+ "version": "1.1.10",
+ "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.10.tgz",
+ "integrity": "sha512-AQC0Dyhzn4EiYEfIUjCdMl0JJ61I2ER9ukf/sLxJUcZHfo+VyEfz2rMJgLZSS1v30OxPQe1cN0LZA1xbcaVfWA==",
+ "requires": {
+ "ignore-walk": "3.0.1",
+ "npm-bundled": "1.0.3"
+ }
+ },
+ "npmlog": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
+ "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
+ "requires": {
+ "are-we-there-yet": "1.1.4",
+ "console-control-strings": "1.1.0",
+ "gauge": "2.7.4",
+ "set-blocking": "2.0.0"
+ }
+ },
+ "number-is-nan": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "requires": {
+ "wrappy": "1.0.2"
+ }
+ },
+ "os-homedir": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
+ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
+ },
+ "os-tmpdir": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
+ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
+ },
+ "osenv": {
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz",
+ "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==",
+ "requires": {
+ "os-homedir": "1.0.2",
+ "os-tmpdir": "1.0.2"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
+ },
+ "process-nextick-args": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
+ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
+ },
+ "rc": {
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.6.tgz",
+ "integrity": "sha1-6xiYnG1PTxYsOZ953dKfODVWgJI=",
+ "requires": {
+ "deep-extend": "0.4.2",
+ "ini": "1.3.5",
+ "minimist": "1.2.0",
+ "strip-json-comments": "2.0.1"
+ },
+ "dependencies": {
+ "minimist": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
+ }
+ }
+ },
+ "readable-stream": {
+ "version": "2.3.5",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz",
+ "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==",
+ "requires": {
+ "core-util-is": "1.0.2",
+ "inherits": "2.0.3",
+ "isarray": "1.0.0",
+ "process-nextick-args": "2.0.0",
+ "safe-buffer": "5.1.1",
+ "string_decoder": "1.0.3",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "rimraf": {
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
+ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
+ "requires": {
+ "glob": "7.1.2"
+ }
+ },
+ "safe-buffer": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
+ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
+ },
+ "safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+ },
+ "sax": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
+ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
+ },
+ "semver": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
+ "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA=="
+ },
+ "set-blocking": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
+ },
+ "signal-exit": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
+ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
+ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
+ "requires": {
+ "code-point-at": "1.1.0",
+ "is-fullwidth-code-point": "1.0.0",
+ "strip-ansi": "3.0.1"
+ }
+ },
+ "string_decoder": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
+ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
+ "requires": {
+ "safe-buffer": "5.1.1"
+ }
+ },
+ "strip-ansi": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
+ "requires": {
+ "ansi-regex": "2.1.1"
+ }
+ },
+ "strip-json-comments": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
+ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo="
+ },
+ "tar": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.1.tgz",
+ "integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==",
+ "requires": {
+ "chownr": "1.0.1",
+ "fs-minipass": "1.2.5",
+ "minipass": "2.2.4",
+ "minizlib": "1.1.0",
+ "mkdirp": "0.5.1",
+ "safe-buffer": "5.1.1",
+ "yallist": "3.0.2"
+ },
+ "dependencies": {
+ "yallist": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
+ "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
+ }
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
+ "wide-align": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
+ "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
+ "requires": {
+ "string-width": "1.0.2"
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
+ }
+ }
+ },
+ "core-js": {
+ "version": "2.5.5",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.5.tgz",
+ "integrity": "sha1-sU3ek2xkDAV5prUMq8wTLdYSfjs="
+ },
+ "jquery": {
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
+ "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg=="
+ },
+ "moment": {
+ "version": "2.22.1",
+ "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz",
+ "integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ=="
+ },
+ "nan": {
+ "version": "2.10.0",
+ "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
+ "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
+ },
+ "regenerator-runtime": {
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
+ "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
+ },
+ "sprintf-js": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz",
+ "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw="
+ },
+ "toastr": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/toastr/-/toastr-2.1.4.tgz",
+ "integrity": "sha1-i0O+ZPudDEFIcURvLbjoyk6V8YE=",
+ "requires": {
+ "jquery": "3.3.1"
+ }
+ },
+ "underscore": {
+ "version": "1.9.0",
+ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
+ "integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A=="
+ },
+ "underscore.string": {
+ "version": "3.3.4",
+ "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.4.tgz",
+ "integrity": "sha1-LCo/n4PmR2L9xF5s6sZRQoZCE9s=",
+ "requires": {
+ "sprintf-js": "1.1.1",
+ "util-deprecate": "1.0.2"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ }
+ }
+}
diff --git a/packages/rocketchat-tokenpass/client/roomType.js b/packages/rocketchat-tokenpass/client/roomType.js
index dcb6f23634cb0..8b1d90d5443f8 100644
--- a/packages/rocketchat-tokenpass/client/roomType.js
+++ b/packages/rocketchat-tokenpass/client/roomType.js
@@ -11,7 +11,7 @@ class TokenPassRoomType extends RoomTypeConfig {
}
condition() {
- const user = Meteor.user();
+ const user = Meteor.users.findOne(Meteor.userId(), {fields: {'services.tokenpass': 1}});
const hasTokenpass = !!(user && user.services && user.services.tokenpass);
return hasTokenpass;
diff --git a/packages/rocketchat-ui-master/client/main.js b/packages/rocketchat-ui-master/client/main.js
index 4e3a23cc7ad16..01ad637b20979 100644
--- a/packages/rocketchat-ui-master/client/main.js
+++ b/packages/rocketchat-ui-master/client/main.js
@@ -197,14 +197,12 @@ Template.main.onRendered(function() {
});
return Tracker.autorun(function() {
const userId = Meteor.userId();
- const user = Meteor.user();
const Show_Setup_Wizard = RocketChat.settings.get('Show_Setup_Wizard');
if ((!userId && Show_Setup_Wizard === 'pending') || (userId && RocketChat.authz.hasRole(userId, 'admin') && Show_Setup_Wizard === 'in_progress')) {
FlowRouter.go('setup-wizard');
}
-
- if (RocketChat.getUserPreference(user, 'hideUsernames')) {
+ if (RocketChat.getUserPreference(userId, 'hideUsernames')) {
$(document.body).on('mouseleave', 'button.thumb', function() {
return RocketChat.tooltip.hide();
});
diff --git a/packages/rocketchat-ui-sidenav/client/chatRoomItem.js b/packages/rocketchat-ui-sidenav/client/chatRoomItem.js
index eb9964bd8b6ec..c095f31e87197 100644
--- a/packages/rocketchat-ui-sidenav/client/chatRoomItem.js
+++ b/packages/rocketchat-ui-sidenav/client/chatRoomItem.js
@@ -1,25 +1,25 @@
Template.chatRoomItem.helpers({
roomData() {
let {name} = this;
- const realNameForDirectMessages = RocketChat.settings.get('UI_Use_Real_Name') && this.t === 'd';
- const realNameForChannel = RocketChat.settings.get('UI_Allow_room_names_with_special_chars') && this.t !== 'd';
- if ((realNameForDirectMessages || realNameForChannel) && this.fname) {
- name = this.fname;
+ if (this.fname) {
+ const realNameForDirectMessages = this.t === 'd' && RocketChat.settings.get('UI_Use_Real_Name');
+ const realNameForChannel = this.t !== 'd' && RocketChat.settings.get('UI_Allow_room_names_with_special_chars');
+ if (realNameForDirectMessages || realNameForChannel) {
+ name = this.fname;
+ }
}
- let unread = false;
- if (((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) && (this.unread > 0)) {
- unread = this.unread;
- }
+ const openedRomm = Tracker.nonreactive(() => Session.get('openedRoom'));
+ const unread = this.unread > 0 ? this.unread : false;
+ // if (this.unread > 0 && (!hasFocus || openedRomm !== this.rid)) {
+ // unread = this.unread;
+ // }
- let active = false;
- if ([this.rid, this._id].find(id => id === Session.get('openedRoom'))) {
- active = true;
- }
+ const active = [this.rid, this._id].includes(id => id === openedRomm);
const archivedClass = this.archived ? 'archived' : false;
- this.alert = !this.hideUnreadStatus && (FlowRouter.getParam('_id') !== this.rid || !document.hasFocus()) && this.alert;
+ this.alert = !this.hideUnreadStatus && this.alert; //&& (!hasFocus || FlowRouter.getParam('_id') !== this.rid);
const icon = RocketChat.roomTypes.getIcon(this.t);
const avatar = !icon;
@@ -34,20 +34,23 @@ Template.chatRoomItem.helpers({
unread,
active,
archivedClass,
- statusClass: this.t === 'd' ? Session.get(`user_${ this.name }_status`) || 'offline' : this.t === 'l' ? RocketChat.roomTypes.getUserStatus(this.t, this.rid) || 'offline' : false
+ status: this.t === 'd' || this.t === 'l'
};
-
roomData.username = roomData.username || roomData.name;
- if (RocketChat.settings.get('Store_Last_Message')) {
- if (this.lastMessage) {
- roomData.lastMessage = this.lastMessage;
- } else {
- const room = RocketChat.models.Rooms.findOne(this.rid || this._id, { fields: { lastMessage: 1 } });
- roomData.lastMessage = room && room.lastMessage || { msg: t('No_messages_yet') };
- }
+ if (!this.lastMessage && RocketChat.settings.get('Store_Last_Message')) {
+ const room = RocketChat.models.Rooms.findOne(this.rid || this._id, { fields: { lastMessage: 1 } });
+ roomData.lastMessage = room && room.lastMessage || { msg: t('No_messages_yet') };
}
-
return roomData;
}
});
+
+RocketChat.callbacks.add('enter-room', (sub) => {
+ const items = $('.rooms-list .sidebar-item');
+ items.filter('.sidebar-item--active').removeClass('sidebar-item--active');
+ if (sub) {
+ items.filter(`[data-id=${ sub._id }]`).addClass('sidebar-item--active');
+ }
+ return sub;
+});
diff --git a/packages/rocketchat-ui-sidenav/client/roomList.js b/packages/rocketchat-ui-sidenav/client/roomList.js
index c3786e929be67..194a95c33d675 100644
--- a/packages/rocketchat-ui-sidenav/client/roomList.js
+++ b/packages/rocketchat-ui-sidenav/client/roomList.js
@@ -1,7 +1,6 @@
/* globals RocketChat */
-import _ from 'underscore';
-
import { UiTextContext } from 'meteor/rocketchat:lib';
+import _ from 'underscore';
Template.roomList.helpers({
rooms() {
@@ -12,11 +11,10 @@ Template.roomList.helpers({
show favorites
show unread
*/
-
if (this.anonymous) {
return RocketChat.models.Rooms.find({t: 'c'}, {sort: {name: 1}});
}
- const user = Meteor.user();
+ const user = Meteor.userId();
const sortBy = RocketChat.getUserPreference(user, 'sidebarSortby') || 'alphabetical';
const query = {
open: true
@@ -25,14 +23,15 @@ Template.roomList.helpers({
const sort = {};
if (sortBy === 'activity') {
- sort.t = 1;
+ sort.lm = -1;
} else { // alphabetical
- sort[this.identifier === 'd' && RocketChat.settings.get('UI_Use_Real_Name') ? 'fname' : 'name'] = /descending/.test(sortBy) ? -1 : 1;
+ sort[this.identifier === 'd' && RocketChat.settings.get('UI_Use_Real_Name') ? 'lowerCaseFName' : 'lowerCaseName'] = /descending/.test(sortBy) ? -1 : 1;
}
if (this.identifier === 'unread') {
query.alert = true;
query.hideUnreadStatus = {$ne: true};
+
return ChatSubscription.find(query, {sort});
}
@@ -68,20 +67,6 @@ Template.roomList.helpers({
query.f = {$ne: favoritesEnabled};
}
}
-
- if (sortBy === 'activity') {
- const list = ChatSubscription.find(query).fetch();
- RocketChat.models.Rooms.find();
- const rooms = RocketChat.models.Rooms._collection._docs._map;
-
- return _.sortBy(list.map(sub => {
- const lm = rooms[sub.rid] && rooms[sub.rid]._updatedAt;
- return {
- ...sub,
- lm: lm && lm.toISOString && lm.toISOString()
- };
- }), 'lm').reverse();
- }
return ChatSubscription.find(query, {sort});
},
@@ -107,11 +92,37 @@ Template.roomList.helpers({
noSubscriptionText() {
const instance = Template.instance();
- const roomType = (instance.data.header || instance.data.identifier);
- return RocketChat.roomTypes.roomTypes[roomType].getUiText(UiTextContext.NO_ROOMS_SUBSCRIBED) || 'No_channels_yet';
+ return RocketChat.roomTypes.roomTypes[instance.data.identifier].getUiText(UiTextContext.NO_ROOMS_SUBSCRIBED) || 'No_channels_yet';
},
showRoomCounter() {
- return RocketChat.getUserPreference(Meteor.user(), 'roomCounterSidebar');
+ return RocketChat.getUserPreference(Meteor.userId(), 'roomCounterSidebar');
+ }
+});
+
+const getLowerCaseNames = (room) => {
+ const lowerCaseNamesRoom = {};
+ lowerCaseNamesRoom.lowerCaseName = room.name ? room.name.toLowerCase() : undefined;
+ lowerCaseNamesRoom.lowerCaseFName = room.fname ? room.fname.toLowerCase() : undefined;
+ return lowerCaseNamesRoom;
+};
+
+// RocketChat.Notifications['onUser']('rooms-changed', );
+
+const mergeSubRoom = (record/*, t*/) => {
+ const room = Tracker.nonreactive(() => RocketChat.models.Rooms.findOne({ _id: record.rid }));
+ if (!room) {
+ return record;
}
+ record.lastMessage = room.lastMessage;
+ record.lm = room._updatedAt;
+ return _.extend(record, getLowerCaseNames(record));
+};
+
+RocketChat.callbacks.add('cachedCollection-received-rooms', (room) => {
+ const $set = {lastMessage : room.lastMessage, lm: room._updatedAt, ...getLowerCaseNames(room)};
+ RocketChat.models.Subscriptions.update({ rid: room._id }, {$set});
});
+RocketChat.callbacks.add('cachedCollection-received-subscriptions', mergeSubRoom);
+RocketChat.callbacks.add('cachedCollection-sync-subscriptions', mergeSubRoom);
+RocketChat.callbacks.add('cachedCollection-loadFromServer-subscriptions', mergeSubRoom);
diff --git a/packages/rocketchat-ui-sidenav/client/sideNav.js b/packages/rocketchat-ui-sidenav/client/sideNav.js
index ce9956e0734f2..3e096e77d48b3 100644
--- a/packages/rocketchat-ui-sidenav/client/sideNav.js
+++ b/packages/rocketchat-ui-sidenav/client/sideNav.js
@@ -34,7 +34,7 @@ Template.sideNav.helpers({
},
sidebarViewMode() {
- const viewMode = RocketChat.getUserPreference(Meteor.user(), 'sidebarViewMode');
+ const viewMode = RocketChat.getUserPreference(Meteor.userId(), 'sidebarViewMode');
return viewMode ? viewMode : 'condensed';
},
@@ -81,11 +81,10 @@ Template.sideNav.onCreated(function() {
this.autorun(() => {
const user = RocketChat.models.Users.findOne(Meteor.userId(), {
fields: {
- 'settings.preferences.roomsListExhibitionMode': 1,
- 'settings.preferences.groupByType': 1
+ 'settings.preferences.sidebarGroupByType': 1
}
});
- const userPref = RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category' && RocketChat.getUserPreference(user, 'groupByType');
+ const userPref = RocketChat.getUserPreference(user, 'sidebarGroupByType');
this.groupedByType.set(userPref ? userPref : RocketChat.settings.get('UI_Group_Channels_By_Type'));
});
});
diff --git a/packages/rocketchat-ui-sidenav/client/sidebarHeader.js b/packages/rocketchat-ui-sidenav/client/sidebarHeader.js
index 15358152479ce..a2eb44b66511f 100644
--- a/packages/rocketchat-ui-sidenav/client/sidebarHeader.js
+++ b/packages/rocketchat-ui-sidenav/client/sidebarHeader.js
@@ -51,7 +51,7 @@ const toolbarButtons = (user) => {
},
{
name: t('View_mode'),
- icon: () => RocketChat.getUserPreference(user, 'sidebarViewMode') ? viewModeIcon[RocketChat.getUserPreference(user, 'sidebarViewMode')] : viewModeIcon.condensed,
+ icon: () => viewModeIcon[RocketChat.getUserPreference(user, 'sidebarViewMode') || 'condensed'],
action: (e) => {
const hideAvatarSetting = RocketChat.getUserPreference(user, 'sidebarHideAvatar');
const config = {
@@ -206,24 +206,20 @@ const toolbarButtons = (user) => {
};
Template.sidebarHeader.helpers({
myUserInfo() {
- if (Meteor.user() == null && RocketChat.settings.get('Accounts_AllowAnonymousRead')) {
+ const id = Meteor.userId();
+
+ if (id == null && RocketChat.settings.get('Accounts_AllowAnonymousRead')) {
return {
username: 'anonymous',
status: 'online'
};
}
-
- const user = Meteor.user() || {};
- const { username } = user;
- const userStatus = Session.get(`user_${ username }_status`);
-
- return {
- username,
- status: userStatus
- };
+ return id && Meteor.users.findOne(id, {fields: {
+ username: 1, status: 1
+ }});
},
toolbarButtons() {
- return toolbarButtons(Meteor.user()).filter(button => !button.condition || button.condition());
+ return toolbarButtons(Meteor.userId()).filter(button => !button.condition || button.condition());
}
});
diff --git a/packages/rocketchat-ui-sidenav/client/sidebarItem.html b/packages/rocketchat-ui-sidenav/client/sidebarItem.html
index 36b84fd8f40b8..abc05e552147f 100644
--- a/packages/rocketchat-ui-sidenav/client/sidebarItem.html
+++ b/packages/rocketchat-ui-sidenav/client/sidebarItem.html
@@ -1,5 +1,8 @@
+
+
+
-