From cd65313c352eda85483ff29e56080a200d8a7cfe Mon Sep 17 00:00:00 2001 From: Mikael Mello Date: Wed, 7 Mar 2018 23:43:44 -0300 Subject: [PATCH 1/6] Changes all 'mergeChannels' to 'groupByType'. Modifies boolean logic as necessary. --- packages/rocketchat-api/server/v1/users.js | 2 +- packages/rocketchat-lib/lib/roomTypes/conversation.js | 3 ++- packages/rocketchat-lib/lib/roomTypes/direct.js | 4 ++-- packages/rocketchat-lib/lib/roomTypes/private.js | 4 ++-- packages/rocketchat-lib/lib/roomTypes/public.js | 4 ++-- packages/rocketchat-ui-sidenav/client/sideNav.js | 8 ++++---- packages/rocketchat-ui-sidenav/client/sortlist.html | 4 ++-- packages/rocketchat-ui-sidenav/client/sortlist.js | 5 ++--- server/methods/channelsList.js | 7 ++++--- server/methods/saveUserPreferences.js | 8 ++++---- 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/packages/rocketchat-api/server/v1/users.js b/packages/rocketchat-api/server/v1/users.js index ab92925e3c39..9b8b0f886889 100644 --- a/packages/rocketchat-api/server/v1/users.js +++ b/packages/rocketchat-api/server/v1/users.js @@ -321,7 +321,7 @@ RocketChat.API.v1.addRoute('users.setPreferences', { authRequired: true }, { sidebarSortby: Match.Optional(String), sidebarViewMode: Match.Optional(String), sidebarHideAvatar: Match.Optional(Boolean), - mergeChannels: Match.Optional(Boolean), + groupByType: Match.Optional(Boolean), muteFocusedConversations: Match.Optional(Boolean) }) }); diff --git a/packages/rocketchat-lib/lib/roomTypes/conversation.js b/packages/rocketchat-lib/lib/roomTypes/conversation.js index 6f7caa07bdc5..9a0f9eb51d8f 100644 --- a/packages/rocketchat-lib/lib/roomTypes/conversation.js +++ b/packages/rocketchat-lib/lib/roomTypes/conversation.js @@ -11,6 +11,7 @@ export class ConversationRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - return RocketChat.getUserPreference(user, 'mergeChannels'); + // returns true only if groupByType is not set + return !RocketChat.getUserPreference(user, 'groupByType'); } } diff --git a/packages/rocketchat-lib/lib/roomTypes/direct.js b/packages/rocketchat-lib/lib/roomTypes/direct.js index 44078e0e9190..d541e3d2776b 100644 --- a/packages/rocketchat-lib/lib/roomTypes/direct.js +++ b/packages/rocketchat-lib/lib/roomTypes/direct.js @@ -62,8 +62,8 @@ export class DirectMessageRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels'); - return !mergeChannels && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']); + const groupByType = RocketChat.getUserPreference(user, 'groupByType'); + return groupByType && RocketChat.authz.hasAtLeastOnePermission(['view-d-room', 'view-joined-room']); } getUserStatus(roomId) { diff --git a/packages/rocketchat-lib/lib/roomTypes/private.js b/packages/rocketchat-lib/lib/roomTypes/private.js index 5522d95a8110..67ee620dd2c3 100644 --- a/packages/rocketchat-lib/lib/roomTypes/private.js +++ b/packages/rocketchat-lib/lib/roomTypes/private.js @@ -44,8 +44,8 @@ export class PrivateRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); - const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels'); - return !mergeChannels && RocketChat.authz.hasAllPermission('view-p-room'); + const groupByType = RocketChat.getUserPreference(user, 'groupByType'); + return groupByType && RocketChat.authz.hasAllPermission('view-p-room'); } isGroupChat() { diff --git a/packages/rocketchat-lib/lib/roomTypes/public.js b/packages/rocketchat-lib/lib/roomTypes/public.js index fb9c9e277ad3..62107db1e735 100644 --- a/packages/rocketchat-lib/lib/roomTypes/public.js +++ b/packages/rocketchat-lib/lib/roomTypes/public.js @@ -43,8 +43,8 @@ export class PublicRoomType extends RoomTypeConfig { condition() { const user = Meteor.user(); // const roomsListExhibitionMode = RocketChat.getUserPreference(user, 'roomsListExhibitionMode'); - const mergeChannels = RocketChat.getUserPreference(user, 'mergeChannels'); - return !mergeChannels && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true); + const groupByType = RocketChat.getUserPreference(user, 'groupByType'); + return groupByType && (RocketChat.authz.hasAtLeastOnePermission(['view-c-room', 'view-joined-room']) || RocketChat.settings.get('Accounts_AllowAnonymousRead') === true); } showJoinLink(roomId) { diff --git a/packages/rocketchat-ui-sidenav/client/sideNav.js b/packages/rocketchat-ui-sidenav/client/sideNav.js index f360e188322e..62ccd691ac08 100644 --- a/packages/rocketchat-ui-sidenav/client/sideNav.js +++ b/packages/rocketchat-ui-sidenav/client/sideNav.js @@ -73,16 +73,16 @@ Template.sideNav.onRendered(function() { }); Template.sideNav.onCreated(function() { - this.mergedChannels = new ReactiveVar(false); + this.groupedByType = new ReactiveVar(false); this.autorun(() => { const user = RocketChat.models.Users.findOne(Meteor.userId(), { fields: { 'settings.preferences.roomsListExhibitionMode': 1, - 'settings.preferences.mergeChannels': 1 + 'settings.preferences.groupByType': 1 } }); - const userPref = RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category' && RocketChat.getUserPreference(user, 'mergeChannels'); - this.mergedChannels.set(userPref ? userPref : RocketChat.settings.get('UI_Merge_Channels_Groups')); + const userPref = RocketChat.getUserPreference(user, 'roomsListExhibitionMode') === 'category' && RocketChat.getUserPreference(user, 'groupByType'); + this.groupedByType.set(userPref ? userPref : !RocketChat.settings.get('UI_Merge_Channels_Groups')); }); }); diff --git a/packages/rocketchat-ui-sidenav/client/sortlist.html b/packages/rocketchat-ui-sidenav/client/sortlist.html index ddb42354fbfe..191651594b9d 100644 --- a/packages/rocketchat-ui-sidenav/client/sortlist.html +++ b/packages/rocketchat-ui-sidenav/client/sortlist.html @@ -22,9 +22,9 @@