Skip to content

Commit

Permalink
Allow room types to provide an own "no subscriptions yet" text
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimpson committed Nov 3, 2017
1 parent bb30caf commit b463b84
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/rocketchat-lib/lib/RoomTypeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const RoomSettingsEnum = {
export const UiTextContext = {
CLOSE_WARNING: 'closeWarning',
HIDE_WARNING: 'hideWarning',
LEAVE_WARNING: 'leaveWarning'
LEAVE_WARNING: 'leaveWarning',
NO_ROOMS_SUBSCRIBED: 'noRoomsSubscribed'
};

export class RoomTypeRouteConfig {
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui-sidenav/client/roomList.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3 class="rooms-list__type">
{{#each room in this}}
{{> chatRoomItem room }}
{{else}}
<p class="rooms-list__empty-room">{{_ "No_channels_yet" }}</p>
<p class="rooms-list__empty-room">{{_ noSubscriptionText }}</p>
{{/each}}
</ul>
{{/if}}
Expand Down
31 changes: 20 additions & 11 deletions packages/rocketchat-ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/* globals RocketChat */
import {UiTextContext} from 'meteor/rocketchat:lib';

Template.roomList.helpers({
rooms() {
if (this.identifier === 'unread') {
const query = {
alert: true,
open: true,
hideUnreadStatus: { $ne: true }
hideUnreadStatus: {$ne: true}
};
return ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }});
return ChatSubscription.find(query, {sort: {'t': 1, 'name': 1}});
}

if (this.anonymous) {
return RocketChat.models.Rooms.find({t: 'c'}, { sort: { name: 1 } });
return RocketChat.models.Rooms.find({t: 'c'}, {sort: {name: 1}});
}


Expand All @@ -19,7 +22,7 @@ Template.roomList.helpers({
const query = {
open: true
};
const sort = { 't': 1, 'name': 1 };
const sort = {'t': 1, 'name': 1};
if (this.identifier === 'f') {
query.f = favoritesEnabled;
} else {
Expand All @@ -28,29 +31,29 @@ Template.roomList.helpers({
types = ['c', 'p', 'd'];
}
if (this.identifier === 'channels' || this.identifier === 'unread') {
types = [ 'c', 'p'];
types = ['c', 'p'];
}
const user = Meteor.user();
if (user && user.settings && user.settings.preferences && user.settings.preferences.roomsListExhibitionMode === 'unread') {
query.$or = [
{ alert: { $ne: true } },
{ hideUnreadStatus: true }
{alert: {$ne: true}},
{hideUnreadStatus: true}
];
}
query.t = { $in: types };
query.f = { $ne: favoritesEnabled };
query.t = {$in: types};
query.f = {$ne: favoritesEnabled};
}
if (this.identifier === 'activity') {
const list = ChatSubscription.find(query).fetch().map(sub => {
const lm = RocketChat.models.Rooms.findOne(sub.rid, { fields: { _updatedAt: 1 }})._updatedAt;
const lm = RocketChat.models.Rooms.findOne(sub.rid, {fields: {_updatedAt: 1}})._updatedAt;
return {
lm: lm && lm.toISOString(),
...sub
};
});
return _.sortBy(list, 'lm').reverse();
}
return ChatSubscription.find(query, { sort });
return ChatSubscription.find(query, {sort});
},

isLivechat() {
Expand All @@ -71,6 +74,12 @@ Template.roomList.helpers({
if (room.header || room.identifier) {
return `type-${ room.header || room.identifier }`;
}
},

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

Expand Down

0 comments on commit b463b84

Please sign in to comment.