diff --git a/client/startup/defaultRoomTypes.coffee b/client/startup/defaultRoomTypes.coffee index 5ef93048cc0..0bba73ffdef 100644 --- a/client/startup/defaultRoomTypes.coffee +++ b/client/startup/defaultRoomTypes.coffee @@ -5,6 +5,10 @@ Meteor.startup -> RocketChat.roomTypes.addType('directMessages', roles); RocketChat.roomTypes.addType('privateGroups', roles); + RocketChat.roomTypes.setIcon('c', 'icon-hash'); + RocketChat.roomTypes.setIcon('d', 'icon-at'); + RocketChat.roomTypes.setIcon('p', 'icon-lock'); + RocketChat.roomTypes.setRoute 'c', 'channel', (sub) -> return { name: sub.name } diff --git a/client/views/app/sideNav/chatRoomItem.coffee b/client/views/app/sideNav/chatRoomItem.coffee index dc25a452a24..c1482357b98 100644 --- a/client/views/app/sideNav/chatRoomItem.coffee +++ b/client/views/app/sideNav/chatRoomItem.coffee @@ -8,9 +8,6 @@ Template.chatRoomItem.helpers if (FlowRouter.getParam('_id') isnt this.rid or not document.hasFocus()) and this.unread > 0 return this.unread - isDirectRoom: -> - return this.t is 'd' - userStatus: -> return 'status-' + (Session.get('user_' + this.name + '_status') or 'offline') if this.t is 'd' return '' @@ -19,10 +16,7 @@ Template.chatRoomItem.helpers return this.name roomIcon: -> - switch this.t - when 'd' then return 'icon-at' - when 'c' then return 'icon-hash' - when 'p' then return 'icon-lock' + return RocketChat.roomTypes.getIcon this.t active: -> if Session.get('openedRoom') is this.rid diff --git a/packages/rocketchat-lib/lib/roomTypes.coffee b/packages/rocketchat-lib/lib/roomTypes.coffee index 69622f99ede..891ec9d27ea 100644 --- a/packages/rocketchat-lib/lib/roomTypes.coffee +++ b/packages/rocketchat-lib/lib/roomTypes.coffee @@ -2,6 +2,7 @@ RocketChat.roomTypes = new class rooms = [] routes = {} publishes = {} + icons = {} ### Sets a route for a room type @param roomType: room type (e.g.: c (for channels), d (for direct channels)) @@ -58,9 +59,22 @@ RocketChat.roomTypes = new class return unless publishes[roomType]? return publishes[roomType].call this, identifier + getIcon = (roomType) -> + return icons[roomType] + + ### + @param roomType: room type (e.g.: c (for channels), d (for direct channels)) + @param iconClass: iconClass to display on sideNav + ### + setIcon = (roomType, iconClass) -> + icons[roomType] = iconClass + addType: addType getTypes: getAllTypes + setIcon: setIcon + getIcon: getIcon + setRoute: setRoute getRoute: getRoute diff --git a/packages/rocketchat-livechat/client/ui.js b/packages/rocketchat-livechat/client/ui.js index 7642597fd25..78c60da223b 100644 --- a/packages/rocketchat-livechat/client/ui.js +++ b/packages/rocketchat-livechat/client/ui.js @@ -1,7 +1,7 @@ Meteor.startup(function() { RocketChat.roomTypes.addType('livechat', ['livechat-agent', 'livechat-manager']); + RocketChat.roomTypes.setIcon('l', 'icon-chat-empty'); RocketChat.roomTypes.setRoute('l', 'live', function(sub) { - console.log('livechat route ->',sub); return { name: sub.name }; });