fix sidebarItem

pull/7748/head
Karl Prieb 9 years ago
parent 2580b0350a
commit fca3fc168c
  1. 3
      packages/rocketchat-ui-sidenav/client/chatRoomItem.html
  2. 75
      packages/rocketchat-ui-sidenav/client/chatRoomItem.js
  3. 2
      packages/rocketchat-ui-sidenav/client/roomList.html
  4. 70
      packages/rocketchat-ui-sidenav/client/roomList.js
  5. 14
      packages/rocketchat-ui-sidenav/client/sidebarItem.js
  6. 2
      packages/rocketchat-ui-sidenav/package.js
  7. 1
      server/methods/saveUserPreferences.js

@ -1,3 +0,0 @@
<template name="chatRoomItem">
{{> sidebarItem data }}
</template>

@ -1,75 +0,0 @@
/* globals KonchatNotification */
Template.chatRoomItem.helpers({
data() {
let name = this.name;
if (RocketChat.settings.get('UI_Use_Real_Name') && this.fname) {
name = this.fname;
}
let unread = false;
if (((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) && (this.unread > 0)) {
unread = this.unread;
}
let active = false;
if (Session.get('openedRoom') && Session.get('openedRoom') === this.rid || Session.get('openedRoom') === this._id) {
active = true;
}
const archivedClass = this.archived ? 'archived' : false;
let alertClass = false;
if (!this.hideUnreadStatus && (FlowRouter.getParam('_id') !== this.rid || !document.hasFocus()) && this.alert) {
alertClass = 'sidebar-content-unread';
}
let statusClass = false;
if (this.t === 'd') {
switch (RocketChat.roomTypes.getUserStatus(this.t, this.rid)) {
case 'online':
statusClass = 'general-success-background';
break;
case 'away':
statusClass = 'general-pending-background';
break;
case 'busy':
statusClass = 'general-error-background';
break;
case 'offline':
statusClass = 'general-inactive-background';
break;
default:
statusClass = 'general-inactive-background';
}
}
return {
...this,
name,
unread,
active,
archivedClass,
alertClass,
statusClass
};
},
canLeave() {
const roomData = Session.get(`roomData${ this.rid }`);
if (!roomData) { return false; }
if (((roomData.cl != null) && !roomData.cl) || (roomData.t === 'd')) {
return false;
} else {
return true;
}
}
});
Template.chatRoomItem.onRendered = function() {
if (!(FlowRouter.getParam('_id') && (FlowRouter.getParam('_id') === this.data.rid)) && !this.data.ls && (this.data.alert === true)) {
return KonchatNotification.newRoom(this.data.rid);
}
};

@ -14,7 +14,7 @@
</h3>
<ul class="rooms-list__list">
{{#each room in this}}
{{> chatRoomItem roomData room }}
{{> sidebarItem roomData room }}
{{else}}
<p class="rooms-list__empty-room sidebar-content">{{_ "No_channels_yet" }}</p>
{{/each}}

@ -1,3 +1,5 @@
/* globals KonchatNotification */
Template.roomList.helpers({
rooms() {
if (this.identifier == 'unread') {
@ -48,10 +50,64 @@ Template.roomList.helpers({
},
roomData(room) {
let name = room.name;
if (RocketChat.settings.get('UI_Use_Real_Name') && room.fname) {
name = room.fname;
}
let unread = false;
if (((FlowRouter.getParam('_id') !== room.rid) || !document.hasFocus()) && (room.unread > 0)) {
unread = room.unread;
}
let active = false;
if (Session.get('openedRoom') && Session.get('openedRoom') === room.rid || Session.get('openedRoom') === room._id) {
active = true;
}
const archivedClass = room.archived ? 'archived' : false;
let alertClass = false;
if (!room.hideUnreadStatus && (FlowRouter.getParam('_id') !== room.rid || !document.hasFocus()) && room.alert) {
alertClass = 'sidebar-content-unread';
}
let statusClass = false;
if (room.t === 'd') {
switch (RocketChat.roomTypes.getUserStatus(room.t, room.rid)) {
case 'online':
statusClass = 'general-success-background';
break;
case 'away':
statusClass = 'general-pending-background';
break;
case 'busy':
statusClass = 'general-error-background';
break;
case 'offline':
statusClass = 'general-inactive-background';
break;
default:
statusClass = 'general-inactive-background';
}
}
// Sound notification
if (!(FlowRouter.getParam('name') === room.name) && !room.ls && room.alert === true) {
KonchatNotification.newRoom(room.rid);
}
return {
...room,
icon: RocketChat.roomTypes.getIcon(room.t),
route: RocketChat.roomTypes.getRouteLink(room.t, room)
route: RocketChat.roomTypes.getRouteLink(room.t, room),
name,
unread,
active,
archivedClass,
alertClass,
statusClass
};
},
@ -91,15 +147,3 @@ Template.roomList.events({
return SideNav.openFlex();
}
});
Template.roomList.onCreated(function() {
// this.autorun(() => {
// const query = {
// alert: true,
// open: true,
// hideUnreadStatus: { $ne: true }
// };
//
// return this.unreadRooms = ChatSubscription.find(query, { sort: { 't': 1, 'name': 1 }});
// });
});

@ -1,5 +1,19 @@
/* globals menu */
Template.sidebarItem.helpers({
canLeave() {
const roomData = Session.get(`roomData${ this.rid }`);
if (!roomData) { return false; }
if (((roomData.cl != null) && !roomData.cl) || (roomData.t === 'd')) {
return false;
} else {
return true;
}
}
});
Template.sidebarItem.events({
'click [data-id]'() {
return menu.close();

@ -20,7 +20,6 @@ Package.onUse(function(api) {
]);
api.addFiles('client/accountBox.html', 'client');
api.addFiles('client/chatRoomItem.html', 'client');
api.addFiles('client/createCombinedFlex.html', 'client');
api.addFiles('client/listChannelsFlex.html', 'client');
api.addFiles('client/listCombinedFlex.html', 'client');
@ -32,7 +31,6 @@ Package.onUse(function(api) {
api.addFiles('client/userStatus.html', 'client');
api.addFiles('client/accountBox.js', 'client');
api.addFiles('client/chatRoomItem.js', 'client');
api.addFiles('client/createCombinedFlex.js', 'client');
api.addFiles('client/listChannelsFlex.js', 'client');
api.addFiles('client/listCombinedFlex.js', 'client');

@ -54,7 +54,6 @@ Meteor.methods({
preferences.unreadRoomsMode = settings.unreadRoomsMode === '1' ? true : false;
}
console.log(settings.roomsListExhibitionMode, 'aaaaaaaaaaa');
preferences.roomsListExhibitionMode = ['category', 'unread', 'activity'].includes(settings.roomsListExhibitionMode) ? settings.roomsListExhibitionMode : 'category';
if (settings.unreadAlert) {
preferences.unreadAlert = settings.unreadAlert === '1' ? true : false;

Loading…
Cancel
Save