Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5ae4f7f
test for improve performance
ggazzo Feb 22, 2018
c66b606
Cleanup code
sampaiodiego Feb 22, 2018
2927a01
Merge tag '0.62.0-rc.1' into improve
ggazzo Feb 22, 2018
3b67af6
Merge
sampaiodiego Feb 22, 2018
e5cd140
fix search
ggazzo Feb 23, 2018
ef6154d
Merge remote-tracking branch 'origin/develop' into improve
ggazzo Mar 1, 2018
70bf31f
Merge branch 'improve' of github.com:RocketChat/Rocket.Chat into improve
ggazzo Mar 1, 2018
0470603
fix lint
ggazzo Mar 1, 2018
0ae4cbd
merge
ggazzo Mar 15, 2018
ea3f334
Merge branch 'develop' into improve
ggazzo Mar 23, 2018
b868d4a
fix active room on sidenav
ggazzo Mar 27, 2018
29c7caf
Merge branch 'develop' into improve
ggazzo Mar 27, 2018
646f090
Merge remote-tracking branch 'origin/improve' into improve
ggazzo Mar 27, 2018
d37cfd8
Merge branch 'develop' into improve
ggazzo Mar 28, 2018
787e15a
Fix user's status when using real names
sampaiodiego Mar 29, 2018
91ffca6
General fixes
sampaiodiego Mar 29, 2018
030a914
Merge branch 'develop' into improve
ggazzo May 5, 2018
d0d7fc8
Merge branch 'develop' into improve
ggazzo May 21, 2018
74640d0
Merge branch 'develop' into improve
karlprieb May 24, 2018
809c3fc
fix reactivity generated by user status changes
karlprieb May 24, 2018
5855e5c
Update cachedCollection.js
ggazzo May 24, 2018
10cef3d
[FIX] Sorting in sidebar rooms list (#10697)
JoseRenan May 24, 2018
3c78855
Update sidebarItem.js
ggazzo May 26, 2018
da5e68f
Update sidebarItem.js
ggazzo May 26, 2018
e98372a
Merge branch 'develop' into improve
ggazzo Jun 7, 2018
9b20604
Merge branch 'develop' into improve
ggazzo Jun 7, 2018
29a1ba5
Remove deprecated roomsListExhibitionMode field
sampaiodiego Jun 7, 2018
098b346
Rename groupByType property to sidebarGroupByType
sampaiodiego Jun 8, 2018
6a0d584
Using correct event for rooms-changed
sampaiodiego Jun 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/rocketchat-api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
})
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-authorization/server/models/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}}));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing

};

RocketChat.models._Base.prototype.addRolesByUserId = function(userId, roles, scope) {
Expand Down
21 changes: 12 additions & 9 deletions packages/rocketchat-lib/client/lib/cachedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -98,7 +105,6 @@ class CachedCollection {
userRelated = true,
useSync = true,
useCache = true,
debug = false,
version = 7,
maxCacheTime = 60*60*24*30,
onSyncData = (/* action, record */) => {}
Expand All @@ -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) {
Expand All @@ -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`);
}
Expand Down Expand Up @@ -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'));

Expand All @@ -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);
Expand Down Expand Up @@ -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 });

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-lib/lib/getUserPreference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 2 additions & 3 deletions packages/rocketchat-lib/lib/roomTypes/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
3 changes: 1 addition & 2 deletions packages/rocketchat-lib/lib/roomTypes/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/rocketchat-lib/lib/roomTypes/favorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
3 changes: 1 addition & 2 deletions packages/rocketchat-lib/lib/roomTypes/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
4 changes: 1 addition & 3 deletions packages/rocketchat-lib/lib/roomTypes/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/rocketchat-lib/lib/roomTypes/unread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
20 changes: 3 additions & 17 deletions packages/rocketchat-lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading