[FIX] Rooms list sorting by activity multiple re-renders and case sensitive sorting alphabetically (#9959)

pull/10727/head^2
Guilherme Gazzo 7 years ago committed by Diego Sampaio
parent 36689b1c0c
commit 725d3e00d0
  1. 3
      packages/rocketchat-api/server/v1/users.js
  2. 2
      packages/rocketchat-authorization/client/lib/models/Users.js
  3. 2
      packages/rocketchat-authorization/server/models/Base.js
  4. 21
      packages/rocketchat-lib/client/lib/cachedCollection.js
  5. 4
      packages/rocketchat-lib/lib/getUserPreference.js
  6. 5
      packages/rocketchat-lib/lib/roomTypes/conversation.js
  7. 3
      packages/rocketchat-lib/lib/roomTypes/direct.js
  8. 3
      packages/rocketchat-lib/lib/roomTypes/favorite.js
  9. 3
      packages/rocketchat-lib/lib/roomTypes/private.js
  10. 4
      packages/rocketchat-lib/lib/roomTypes/public.js
  11. 3
      packages/rocketchat-lib/lib/roomTypes/unread.js
  12. 20
      packages/rocketchat-lib/server/startup/settings.js
  13. 568
      packages/rocketchat-livechat/.app/package-lock.json
  14. 2
      packages/rocketchat-tokenpass/client/roomType.js
  15. 4
      packages/rocketchat-ui-master/client/main.js
  16. 49
      packages/rocketchat-ui-sidenav/client/chatRoomItem.js
  17. 57
      packages/rocketchat-ui-sidenav/client/roomList.js
  18. 7
      packages/rocketchat-ui-sidenav/client/sideNav.js
  19. 20
      packages/rocketchat-ui-sidenav/client/sidebarHeader.js
  20. 15
      packages/rocketchat-ui-sidenav/client/sidebarItem.html
  21. 85
      packages/rocketchat-ui-sidenav/client/sidebarItem.js
  22. 4
      packages/rocketchat-ui-sidenav/client/sortlist.html
  23. 12
      packages/rocketchat-ui-sidenav/client/sortlist.js
  24. 2
      packages/rocketchat-ui-sidenav/client/toolbar.js
  25. 9
      server/methods/channelsList.js
  26. 15
      server/methods/saveUserPreferences.js
  27. 12
      server/startup/migrations/v125.js
  28. 1
      tests/data/user.js
  29. 2
      tests/end-to-end/api/00-miscellaneous.js
  30. 8
      tests/end-to-end/ui/11-admin.js
  31. 3
      tests/pageobjects/administration.page.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)
})
});

@ -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) {

@ -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) {

@ -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);

@ -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];

@ -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');
}
}

@ -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']);
}

@ -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');
}
}

@ -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');
}

@ -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);
}

@ -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');
}
}

@ -304,24 +304,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',

@ -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="
}
}
}

@ -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;

@ -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();
});

@ -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;
});

@ -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);

@ -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'));
});
});

@ -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());
}
});

@ -1,5 +1,8 @@
<template name="sidebarItemStatus">
<div class="sidebar-item__user-status sidebar-item__user-status--{{statusClass}}"></div>
</template>
<template name="sidebarItem">
<li class="sidebar-item {{#if or unread alert }}sidebar-item--unread{{/if}} {{#if active}}sidebar-item--active{{/if}} {{#if toolbar}}popup-item{{/if}}" data-id="{{_id}}">
<li class="sidebar-item{{#if or unread alert }} sidebar-item--unread{{/if}}{{#if active}} sidebar-item--active{{/if}}{{#if toolbar}} popup-item{{/if}}" data-id="{{_id}}">
<a class="sidebar-item__link" href="{{#if route}}{{route}}{{else}}{{pathFor pathSection group=pathGroup}}{{/if}}" title="{{name}}">
{{#unless isLivechatQueue}}
@ -18,11 +21,12 @@
</div>
{{/unless}}
<div class="sidebar-item__body">
{{# let extended=isExtendedViewMode}}
<div class="sidebar-item__message">
<div class="sidebar-item__message-top">
<div class="sidebar-item__name">
{{#if statusClass}}
<div class="sidebar-item__user-status sidebar-item__user-status--{{statusClass}}"></div>
{{#if status}}
{{> sidebarItemStatus}}
{{/if}}
{{#unless darken}}
{{#if icon}}
@ -38,14 +42,14 @@
{{/if}}
</div>
</div>
{{#if isExtendedViewMode}}
{{#if extended}}
{{#if lastMessageTs}}
<span class="sidebar-item__time">{{lastMessageTs}}</span>
{{/if}}
{{/if}}
</div>
<div class="sidebar-item__message-bottom">
{{#if isExtendedViewMode}}
{{#if extended}}
{{#if lastMessage}}
<div class="sidebar-item__last-message">{{{lastMessage}}}</div>
{{/if}}
@ -55,6 +59,7 @@
{{/if}}
</div>
</div>
{{/let}}
{{#if isRoom}}
<div class="sidebar-item__menu">

@ -10,7 +10,7 @@ Template.sidebarItem.helpers({
return this.rid || this._id;
},
isExtendedViewMode() {
return RocketChat.getUserPreference(Meteor.user(), 'sidebarViewMode') === 'extended';
return RocketChat.getUserPreference(Meteor.userId(), 'sidebarViewMode') === 'extended';
},
lastMessage() {
return this.lastMessage && Template.instance().renderedMessage;
@ -22,59 +22,65 @@ Template.sidebarItem.helpers({
return `background-color: ${ RocketChat.getAvatarColor(this.name) }`;
},
mySelf() {
return this.t === 'd' && this.name === Meteor.user().username;
return this.t === 'd' && this.name === Template.instance().user.username;
},
isLivechatQueue() {
return this.pathSection === 'livechat-queue';
}
});
Template.sidebarItem.onCreated(function() {
function timeAgo(time) {
const now = new Date();
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
return (
now.getDate() === time.getDate() && moment(time).format('LT') ||
yesterday.getDate() === time.getDate() && t('yesterday') ||
moment(time).format('L')
);
function timeAgo(time) {
const now = new Date();
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
return (
now.getDate() === time.getDate() && moment(time).format('LT') ||
yesterday.getDate() === time.getDate() && t('yesterday') ||
moment(time).format('L')
);
}
function setLastMessageTs(instance, ts) {
if (instance.timeAgoInterval) {
clearInterval(instance.timeAgoInterval);
}
instance.lastMessageTs.set(timeAgo(ts));
instance.timeAgoInterval = setInterval(() => {
requestAnimationFrame(() => instance.lastMessageTs.set(timeAgo(ts)));
}, 60000);
}
Template.sidebarItem.onCreated(function() {
this.user = RocketChat.models.Users.findOne(Meteor.userId(), {fields: {username: 1}});
this.lastMessageTs = new ReactiveVar();
this.timeAgoInterval;
function setLastMessageTs(instance, ts) {
if (instance.timeAgoInterval) {
Meteor.clearInterval(instance.timeAgoInterval);
}
instance.lastMessageTs.set(timeAgo(ts));
instance.timeAgoInterval = Meteor.setInterval(() => {
instance.lastMessageTs.set(timeAgo(ts));
}, 60000);
}
// console.log('sidebarItem.onCreated');
this.autorun(() => {
const currentData = Template.currentData();
if (currentData.lastMessage) {
if (currentData.lastMessage._id) {
const otherUser = RocketChat.settings.get('UI_Use_Real_Name') ? currentData.lastMessage.u.name || currentData.lastMessage.u.username : currentData.lastMessage.u.username;
const renderedMessage = renderMessageBody(currentData.lastMessage).replace(/<br\s?\\?>/g, ' ');
const sender = Meteor.userId() === currentData.lastMessage.u._id ? t('You') : otherUser;
if (!currentData.lastMessage || RocketChat.getUserPreference(Meteor.userId(), 'sidebarViewMode') !== 'extended') {
return clearInterval(this.timeAgoInterval);
}
if (!currentData.lastMessage._id) {
return this.renderedMessage = currentData.lastMessage.msg;
}
if (currentData.t === 'd' && Meteor.userId() !== currentData.lastMessage.u._id) {
this.renderedMessage = currentData.lastMessage.msg === '' ? t('Sent_an_attachment') : renderedMessage;
} else {
this.renderedMessage = currentData.lastMessage.msg === '' ? t('user_sent_an_attachment', {user: sender}) : `${ sender }: ${ renderedMessage }`;
}
const otherUser = RocketChat.settings.get('UI_Use_Real_Name') ? currentData.lastMessage.u.name || currentData.lastMessage.u.username : currentData.lastMessage.u.username;
const renderedMessage = renderMessageBody(currentData.lastMessage).replace(/<br\s?\\?>/g, ' ');
const sender = this.user._id === currentData.lastMessage.u._id ? t('You') : otherUser;
setLastMessageTs(this, currentData.lastMessage.ts);
} else {
this.renderedMessage = currentData.lastMessage.msg;
}
if (currentData.t === 'd' && Meteor.userId() !== currentData.lastMessage.u._id) {
this.renderedMessage = currentData.lastMessage.msg === '' ? t('Sent_an_attachment') : renderedMessage;
} else {
this.renderedMessage = currentData.lastMessage.msg === '' ? t('user_sent_an_attachment', {user: sender}) : `${ sender }: ${ renderedMessage }`;
}
setLastMessageTs(this, currentData.lastMessage.ts);
});
});
@ -171,3 +177,10 @@ Template.sidebarItem.events({
popover.open(config);
}
});
Template.sidebarItemStatus.helpers({
statusClass() {
const instance = Template.instance();
return instance.data.t === 'd' ? Session.get(`user_${ instance.data.username }_status`) || 'offline' : instance.data.t === 'l' ? RocketChat.roomTypes.getUserStatus('l', instance.data.rid) || 'offline' : false;
}
});

@ -22,9 +22,9 @@
</ul>
<span class="rc-popover__divider"></span>
<ul class="rc-popover__list">
<li class="rc-popover__item {{bold 'groupByType'}}">
<li class="rc-popover__item {{bold 'sidebarGroupByType'}}">
<label class="rc-popover__label">
<input type="checkbox" name="groupByType" class="hidden" checked="{{checked 'groupByType'}}"/>
<input type="checkbox" name="sidebarGroupByType" class="hidden" checked="{{checked 'sidebarGroupByType'}}"/>
<span class="rc-popover__icon">
{{> icon block="rc-popover__icon-element" icon='sort-amount-down' }}
</span>

@ -1,18 +1,18 @@
/* globals popover */
const checked = function(prop, field) {
const user = Meteor.user();
const user = Meteor.userId();
if (prop === 'sidebarShowFavorites') {
return RocketChat.getUserPreference(user, 'sidebarShowFavorites');
}
if (prop === 'groupByType') {
return RocketChat.getUserPreference(user, 'groupByType');
if (prop === 'sidebarGroupByType') {
return RocketChat.getUserPreference(user, 'sidebarGroupByType');
}
if (prop === 'sidebarShowUnread') {
return RocketChat.getUserPreference(user, 'sidebarShowUnread');
}
if (prop === 'sidebarSortby') {
return (RocketChat.getUserPreference(user, 'sidebarSortby') || 'activity') === field;
return (RocketChat.getUserPreference(user, 'sidebarSortby') || 'alphabetical') === field;
}
};
@ -41,7 +41,3 @@ Template.sortlist.events({
popover.close();
}
});
Template.sortlist.onRendered(function() {
});

@ -172,7 +172,7 @@ Template.toolbar.helpers({
resultsFromClient = collection.find(query, {limit: 20, sort: {unread: -1, ls: -1}}).fetch();
const resultsFromClientLength = resultsFromClient.length;
const user = Meteor.user();
const user = Meteor.users.findOne(Meteor.userId(), {fields: {name: 1, username:1}});
if (user) {
usernamesFromClient = [user];
}

@ -61,8 +61,13 @@ Meteor.methods({
}
if (channelType !== 'public' && RocketChat.authz.hasPermission(Meteor.userId(), 'view-p-room')) {
const user = Meteor.user();
const userPref = RocketChat.getUserPreference(user, 'groupByType') && RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category';
const user = RocketChat.models.Users.findOne(Meteor.userId(), {
fields: {
username: 1,
'settings.preferences.sidebarGroupByType': 1
}
});
const userPref = RocketChat.getUserPreference(user, 'sidebarGroupByType');
const globalPref = RocketChat.settings.get('UI_Group_Channels_By_Type');
// needs to negate globalPref because userPref represents its opposite
const groupByType = userPref !== undefined ? userPref : globalPref;

@ -10,7 +10,6 @@ Meteor.methods({
collapseMediaByDefault: Match.Optional(Boolean),
autoImageLoad: Match.Optional(Boolean),
emailNotificationMode: Match.Optional(String),
roomsListExhibitionMode: Match.Optional(String),
unreadAlert: Match.Optional(Boolean),
notificationsSoundVolume: Match.Optional(Number),
desktopNotifications: Match.Optional(String),
@ -31,14 +30,10 @@ Meteor.methods({
sidebarSortby: Match.Optional(String),
sidebarViewMode: Match.Optional(String),
sidebarHideAvatar: Match.Optional(Boolean),
sidebarGroupByType: Match.Optional(Boolean),
muteFocusedConversations: Match.Optional(Boolean)
};
check(settings, Match.ObjectIncluding(keys));
if (settings.groupByType) {
check(settings, Match.ObjectIncluding({
groupByType: Match.OneOf(Number, Boolean) //eslint-disable-line new-cap
}));
}
const user = Meteor.user();
if (!user) {
@ -59,14 +54,6 @@ Meteor.methods({
RocketChat.models.Users.setLanguage(user._id, settings.language);
}
if (settings.groupByType != null) {
settings.groupByType = ['1', true].includes(settings.groupByType);
}
if (settings.roomsListExhibitionMode != null) {
settings.roomsListExhibitionMode = ['category', 'unread', 'activity'].includes(settings.roomsListExhibitionMode) ? settings.roomsListExhibitionMode : 'category';
}
// Keep compatibility with old values
if (settings.emailNotificationMode === 'all') {
settings.emailNotificationMode = 'mentions';

@ -0,0 +1,12 @@
RocketChat.Migrations.add({
version: 125,
up() {
RocketChat.models.Users.update({}, {
$rename: {
'settings.preferences.groupByType': 'settings.preferences.sidebarGroupByType'
}
}, {
multi: true
});
}
});

@ -16,7 +16,6 @@ export const preferences = {
collapseMediaByDefault: false,
autoImageLoad: true,
emailNotificationMode: 'mentions',
roomsListExhibitionMode: 'category',
unreadAlert: true,
notificationsSoundVolume: 100,
desktopNotifications: 'default',

@ -78,7 +78,7 @@ describe('miscellaneous', function() {
const allUserPreferencesKeys = ['enableAutoAway', 'idleTimeoutLimit', 'desktopNotificationDuration', 'audioNotifications',
'desktopNotifications', 'mobileNotifications', 'unreadAlert', 'useEmojis', 'convertAsciiEmoji', 'autoImageLoad',
'saveMobileBandwidth', 'collapseMediaByDefault', 'hideUsernames', 'hideRoles', 'hideFlexTab', 'hideAvatars',
'roomsListExhibitionMode', 'sidebarViewMode', 'sidebarHideAvatar', 'sidebarShowUnread', 'sidebarShowFavorites',
'sidebarViewMode', 'sidebarHideAvatar', 'sidebarShowUnread', 'sidebarShowFavorites', 'sidebarGroupByType',
'sendOnEnter', 'messageViewMode', 'emailNotificationMode', 'roomCounterSidebar', 'newRoomNotification', 'newMessageNotification',
'muteFocusedConversations', 'notificationsSoundVolume'];
expect(res.body).to.have.property('success', true);

@ -875,14 +875,6 @@ describe('[Administration]', () => {
admin.accountsHideAvatarsFalse.isSelected().should.be.true;
});
it('it should show the sidebar channel list mode field', () => {
admin.accountsRoomsListExhibitionMode.click();
admin.accountsRoomsListExhibitionMode.isVisible().should.be.true;
});
it('the sidebar channel list mode field value should be category', () => {
admin.accountsRoomsListExhibitionMode.getValue().should.equal('category');
});
it('it should show the enter key behavior field', () => {
admin.accountsSendOnEnter.click();
admin.accountsSendOnEnter.isVisible().should.be.true;

@ -185,9 +185,6 @@ class Administration extends Page {
get accountsHideAvatarsFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_hideAvatars"]'); }
get accountsHideAvatarsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_hideAvatars"]'); }
get accountsRoomsListExhibitionMode() { return browser.element('[name="Accounts_Default_User_Preferences_roomsListExhibitionMode"]'); }
get accountsRoomsListExhibitionModeReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_roomsListExhibitionMode"]'); }
get accountsMergeChannelsTrue() { return browser.element('label:nth-of-type(1) [name="Accounts_Default_User_Preferences_mergeChannels"]'); }
get accountsMergeChannelsFalse() { return browser.element('label:nth-of-type(2) [name="Accounts_Default_User_Preferences_mergeChannels"]'); }
get accountsMergeChannelsReset() { return browser.element('.reset-setting[data-setting="Accounts_Default_User_Preferences_mergeChannels"]'); }

Loading…
Cancel
Save