Skip to content

Commit

Permalink
Disabling Favorites based on settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsecrieru committed Sep 25, 2015
1 parent 51c242c commit dd19e5c
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
14 changes: 12 additions & 2 deletions client/views/app/room.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
isSubscribed = (_id) ->
return ChatSubscription.find({ rid: _id }).count() > 0

favoritesEnabled = ->
return !RocketChat.settings.get 'Disable_Favorite_Rooms'


# @TODO bug com o botão para "rolar até o fim" (novas mensagens) quando há uma mensagem com texto que gere rolagem horizontal
Template.room.helpers
favorite: ->
sub = ChatSubscription.findOne { rid: this._id }, { fields: { f: 1 } }
return 'icon-star favorite-room' if sub?.f? and sub.f
return 'icon-star favorite-room' if sub?.f? and sub.f and favoritesEnabled
return 'icon-star-empty'

subscribed: ->
return ChatSubscription.find({ rid: this._id }).count() > 0
return isSubscribed(this._id)

messagesHistory: ->
return ChatMessage.find { rid: this._id, t: { '$ne': 't' } }, { sort: { ts: 1 } }
Expand Down Expand Up @@ -231,6 +238,9 @@ Template.room.helpers
adminClass: ->
return 'admin' if RocketChat.authz.hasRole(Meteor.userId(), 'admin')

showToggleFavorite: ->
return true if isSubscribed(this._id) and favoritesEnabled()

Template.room.events
"touchstart .message": (e, t) ->
message = this._arguments[1]
Expand Down
2 changes: 1 addition & 1 deletion client/views/app/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<header class="fixed-title">
{{> burger}}
<h2>
{{#if subscribed}}
{{#if showToggleFavorite}}
<a href="#favorite" class="toggle-favorite"><i class="{{favorite}}"></i></a>
{{/if}}
<i class="{{roomIcon}} status-{{userStatus}}"></i>
Expand Down
13 changes: 10 additions & 3 deletions client/views/app/sideNav/channels.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ Template.channels.helpers
return 'active' if ChatSubscription.findOne({ t: { $in: ['c']}, f: { $ne: true }, open: true, rid: Session.get('openedRoom') }, { fields: { _id: 1 } })?

rooms: ->
return ChatSubscription.find { t: { $in: ['c']}, f: { $ne: true }, open: true }, { sort: 't': 1, 'name': 1 }
query =
t: { $in: ['c']},
open: true

if !RocketChat.settings.get 'Disable_Favorite_Rooms'
query.f = { $ne: true }

return ChatSubscription.find query, { sort: 't': 1, 'name': 1 }

Template.channels.events
'click .add-room': (e, instance) ->
if RocketChat.authz.hasAtLeastOnePermission('create-c')
SideNav.setFlex "createChannelFlex"
SideNav.openFlex()
else
e.preventDefault()
else
e.preventDefault()

'click .more-channels': ->
SideNav.setFlex "listChannelsFlex"
Expand Down
2 changes: 2 additions & 0 deletions client/views/app/sideNav/sideNav.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Template.sideNav.helpers
return SideNav.getFlex().data
footer: ->
return RocketChat.settings.get 'Layout_Sidenav_Footer'
showStarredRooms: ->
return !RocketChat.settings.get 'Disable_Favorite_Rooms'

Template.sideNav.events
'click .close-flex': ->
Expand Down
4 changes: 3 additions & 1 deletion client/views/app/sideNav/sideNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
</div>
<div class="rooms-list">
<div class="wrapper">
{{> starredRooms }}
{{#if showStarredRooms }}
{{> starredRooms }}
{{/if}}
{{> channels }}
{{> directMessages }}
{{> privateGroups }}
Expand Down
1 change: 1 addition & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"Delete" : "Delete",
"Deleted" : "Deleted!",
"Direct_Messages" : "Direct Messages",
"Disable_Favorite_Rooms" : "Disable Favorites",
"Disable_New_Message_Notification" : "Disable New Message Notification",
"Disable_New_Room_Notification" : "Disable New Room Notification",
"Drop_to_upload_file" : "Drop to upload file",
Expand Down
1 change: 1 addition & 0 deletions i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"Delete" : "Deletar",
"Deleted" : "Deletado!",
"Direct_Messages" : "Mensagens Diretas",
"Disable_Favorite_Rooms" : "Desabilitar Favoritos",
"Disable_New_Message_Notification" : "Desativar notificações de nova mensagem",
"Disable_New_Room_Notification" : "Desativar notificações de nova sala",
"Drop_to_upload_file" : "Largue para enviar arquivos",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/settings/server/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RocketChat.settings.add 'Accounts_OAuth_Twitter_secret', '', { type: 'string', g
RocketChat.settings.addGroup 'General'
RocketChat.settings.add 'Site_Name', 'Rocket.Chat', { type: 'string', group: 'General', public: true }
RocketChat.settings.add 'Allow_Invalid_SelfSigned_Certs', false, { type: 'boolean', group: 'General' }
RocketChat.settings.add 'Disable_Favorite_Rooms', false, { type: 'boolean', group: 'General' }

RocketChat.settings.addGroup 'API'
RocketChat.settings.add 'API_Analytics', '', { type: 'string', group: 'API', public: true }
Expand Down

0 comments on commit dd19e5c

Please sign in to comment.