Closes #636; Allows a user to disable emojis completely or disable converting ascii to emoji

pull/671/head
Marcelo Schmidt 10 years ago
parent a7edf3cb16
commit 1e61964770
  1. 2
      client/routes/router.coffee
  2. 24
      client/views/account/accountPreferences.coffee
  3. 23
      client/views/account/accountPreferences.html
  4. 2
      i18n/en.i18n.json
  5. 2
      lib/emojione.ascii.coffee
  6. 10
      packages/rocketchat-emojione/emojione.coffee
  7. 8
      packages/rocketchat-emojione/rocketchat.coffee
  8. 6
      packages/rocketchat-lib/lib/callbacks.coffee
  9. 6
      server/methods/saveUserPreferences.coffee

@ -74,7 +74,7 @@ FlowRouter.route '/account/:group?',
action: (params) ->
unless params.group
params.group = 'Profile'
params.group = 'Preferences'
params.group = _.capitalize params.group, true
BlazeLayout.render 'main', { center: "account#{params.group}" }

@ -1,6 +1,10 @@
Template.accountPreferences.helpers
checked: (property, value) ->
currentValue = !!Meteor.user()?.settings?.preferences?[property]
checked: (property, value, defaultValue) ->
if not Meteor.user()?.settings?.preferences?[property]? and defaultValue is true
currentValue = value
else if Meteor.user()?.settings?.preferences?[property]?
currentValue = !!Meteor.user()?.settings?.preferences?[property]
return currentValue is value
Template.accountPreferences.onCreated ->
@ -8,6 +12,16 @@ Template.accountPreferences.onCreated ->
settingsTemplate.child ?= []
settingsTemplate.child.push this
@useEmojis = new ReactiveVar not Meteor.user()?.settings?.preferences?.useEmojis? or Meteor.user().settings.preferences.useEmojis
instance = @
@autorun ->
if instance.useEmojis.get()
Tracker.afterFlush ->
$('#convertAsciiEmoji').show()
else
Tracker.afterFlush ->
$('#convertAsciiEmoji').hide()
@clearForm = ->
@save = ->
@ -16,6 +30,9 @@ Template.accountPreferences.onCreated ->
data.disableNewRoomNotification = $('input[name=disableNewRoomNotification]:checked').val()
data.disableNewMessageNotification = $('input[name=disableNewMessageNotification]:checked').val()
data.useEmojis = $('input[name=useEmojis]:checked').val()
data.convertAsciiEmoji = $('input[name=convertAsciiEmoji]:checked').val()
Meteor.call 'saveUserPreferences', data, (error, results) ->
if results
toastr.success t('Preferences_saved')
@ -32,3 +49,6 @@ Template.accountPreferences.onRendered ->
Template.accountPreferences.events
'click .submit button': (e, t) ->
t.save()
'change input[name=useEmojis]': (e, t) ->
t.useEmojis.set $(e.currentTarget).val() is '1'

@ -9,6 +9,25 @@
<div class="content">
<div class="rocket-form">
<fieldset>
<div class="section">
<h1>{{_ "Messages"}}</h1>
<div class="section-content">
<div class="input-line double-col">
<label>{{_ "Use_Emojis"}}</label>
<div>
<label><input type="radio" name="useEmojis" value="1" checked="{{checked 'useEmojis' true true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="useEmojis" value="0" checked="{{checked 'useEmojis' false}}" /> {{_ "False"}}</label>
</div>
</div>
<div class="input-line double-col" id="convertAsciiEmoji">
<label>{{_ "Convert_Ascii_Emojis"}}</label>
<div>
<label><input type="radio" name="convertAsciiEmoji" value="1" checked="{{checked 'convertAsciiEmoji' true true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="convertAsciiEmoji" value="0" checked="{{checked 'convertAsciiEmoji' false}}" /> {{_ "False"}}</label>
</div>
</div>
</div>
</div>
<div class="section">
<h1>{{_ "Sound"}}</h1>
<div class="section-content">
@ -16,14 +35,14 @@
<label>{{_ "Disable_New_Room_Notification"}}</label>
<div>
<label><input type="radio" name="disableNewRoomNotification" value="1" checked="{{checked 'disableNewRoomNotification' true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="disableNewRoomNotification" value="0" checked="{{checked 'disableNewRoomNotification' false}}" /> {{_ "False"}}</label>
<label><input type="radio" name="disableNewRoomNotification" value="0" checked="{{checked 'disableNewRoomNotification' false true}}" /> {{_ "False"}}</label>
</div>
</div>
<div class="input-line double-col">
<label>{{_ "Disable_New_Message_Notification"}}</label>
<div>
<label><input type="radio" name="disableNewMessageNotification" value="1" checked="{{checked 'disableNewMessageNotification' true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="disableNewMessageNotification" value="0" checked="{{checked 'disableNewMessageNotification' false}}" /> {{_ "False"}}</label>
<label><input type="radio" name="disableNewMessageNotification" value="0" checked="{{checked 'disableNewMessageNotification' false true}}" /> {{_ "False"}}</label>
</div>
</div>
</div>

@ -68,6 +68,7 @@
"Confirm_password" : "Confirm your password",
"Contact" : "Contact",
"Conversation" : "Conversation",
"Convert_Ascii_Emojis" : "Convert ASCII to Emoji",
"Create_new" : "Create new",
"Create_new_direct_message_room" : "Create a new direct message room",
"Create_new_private_group" : "Create a new private group",
@ -278,6 +279,7 @@
"True" : "True",
"Unnamed" : "Unnamed",
"Upload_file_question" : "Upload file?",
"Use_Emojis" : "Use Emojis",
"Use_initials_avatar" : "Use your username initials",
"use_menu" : "Use the side menu to access your rooms and chats",
"Use_service_avatar" : "Use %s avatar",

@ -1,2 +0,0 @@
# Add ascii support to emojione
emojione?.ascii = true

@ -10,4 +10,12 @@ class Emojione
return message
RocketChat.callbacks.add 'renderMessage', Emojione, RocketChat.callbacks.priority.LOW
RocketChat.callbacks.add 'renderMessage', Emojione, RocketChat.callbacks.priority.LOW
if Meteor.isClient
Meteor.startup ->
Tracker.autorun ->
if Meteor.user()?.settings?.preferences?.useEmojis or not Meteor.user()?.settings?.preferences?.useEmojis?
RocketChat.callbacks.add 'renderMessage', Emojione, RocketChat.callbacks.priority.LOW
else
RocketChat.callbacks.remove 'renderMessage', 'Emojione'

@ -3,3 +3,11 @@ RocketChat.emoji = emojione
# RocketChat.emoji.list is the collection of emojis
RocketChat.emoji.list = emojione.emojioneList
# RocketChat.emoji.class is the name of the registered class for emojis
RocketChat.emoji.class = 'Emojione'
# Additional settings -- ascii emojis
Meteor.startup ->
Tracker.autorun ->
emojione?.ascii = if Meteor.user()?.settings?.preferences?.convertAsciiEmoji? then Meteor.user().settings.preferences.convertAsciiEmoji else true

@ -27,6 +27,12 @@ RocketChat.callbacks.add = (hook, callback, priority) ->
priority = RocketChat.callbacks.priority.MEDIUM
callback.priority = priority
RocketChat.callbacks[hook] ?= []
# Avoid adding the same callback twice
for cb in RocketChat.callbacks[hook]
if cb.name is callback.name
return
RocketChat.callbacks[hook].push callback
return

@ -10,6 +10,12 @@ Meteor.methods
if settings.disableNewMessageNotification?
preferences.disableNewMessageNotification = if settings.disableNewMessageNotification is "1" then true else false
if settings.useEmojis?
preferences.useEmojis = if settings.useEmojis is "1" then true else false
if settings.convertAsciiEmoji?
preferences.convertAsciiEmoji = if settings.convertAsciiEmoji is "1" then true else false
Meteor.users.update Meteor.userId(), { $set: { "settings.preferences": preferences } }

Loading…
Cancel
Save