Skip to content

Commit

Permalink
Merge pull request #718 from RocketChat/bugfix-537
Browse files Browse the repository at this point in the history
Added Toggle for auto load image, also bandwidth override to enable on mobile
  • Loading branch information
engelgabriel committed Sep 7, 2015
2 parents 2157fc7 + 699f897 commit bc6f656
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
12 changes: 7 additions & 5 deletions client/views/account/accountPreferences.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Template.accountPreferences.helpers
currentValue = value
else if Meteor.user()?.settings?.preferences?[property]?
currentValue = !!Meteor.user()?.settings?.preferences?[property]

return currentValue is value

Template.accountPreferences.onCreated ->
Expand All @@ -23,7 +23,7 @@ Template.accountPreferences.onCreated ->
$('#convertAsciiEmoji').hide()

@clearForm = ->

@save = ->
instance = @
data = {}
Expand All @@ -32,12 +32,14 @@ Template.accountPreferences.onCreated ->
data.disableNewMessageNotification = $('input[name=disableNewMessageNotification]:checked').val()
data.useEmojis = $('input[name=useEmojis]:checked').val()
data.convertAsciiEmoji = $('input[name=convertAsciiEmoji]:checked').val()

data.saveMobileBandwidth = $('input[name=saveMobileBandwidth]:checked').val()
data.autoImageLoad = $('input[name=autoImageLoad]:checked').val()

Meteor.call 'saveUserPreferences', data, (error, results) ->
if results
if results
toastr.success t('Preferences_saved')
instance.clearForm()

if error
toastr.error error.reason

Expand Down
14 changes: 14 additions & 0 deletions client/views/account/accountPreferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ <h1>{{_ "Messages"}}</h1>
<label><input type="radio" name="convertAsciiEmoji" value="0" checked="{{checked 'convertAsciiEmoji' false}}" /> {{_ "False"}}</label>
</div>
</div>
<div class="input-line double-col" id="autoImageLoad">
<label>{{_ "Auto_Load_Images"}}</label>
<div>
<label><input type="radio" name="autoImageLoad" value="1" checked="{{checked 'autoImageLoad' true true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="autoImageLoad" value="0" checked="{{checked 'autoImageLoad' false}}" /> {{_ "False"}}</label>
</div>
</div>
<div class="input-line double-col" id="saveMobileBandwidth">
<label>{{_ "Save_Mobile_Bandwidth"}}</label>
<div>
<label><input type="radio" name="saveMobileBandwidth" value="1" checked="{{checked 'saveMobileBandwidth' true true}}" /> {{_ "True"}}</label>
<label><input type="radio" name="saveMobileBandwidth" value="0" checked="{{checked 'saveMobileBandwidth' false}}" /> {{_ "False"}}</label>
</div>
</div>
</div>
</div>
<div class="section">
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"Away_female" : "Away",
"away_male" : "away",
"Away_male" : "Away",
"Auto_Load_Images" : "Auto Load Images",
"Back_to_login" : "Back to login",
"bold" : "bold",
"busy" : "busy",
Expand Down Expand Up @@ -227,6 +228,7 @@
"room_user_count" : "%s users",
"Save" : "Save",
"Save_changes" : "Save changes",
"Save_Mobile_Bandwidth" : "Save Mobile Bandwidth",
"Search" : "Search",
"Search_settings" : "Search settings",
"seconds" : "seconds",
Expand Down
9 changes: 8 additions & 1 deletion packages/rocketchat-oembed/client/oembedImageWidget.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Template.oembedImageWidget.helpers
showImage: ->
return @downloadImages is true or not Meteor.Device.isPhone()

if Meteor.user()?.settings?.preferences?.autoImageLoad is false
return false

if Meteor.Device.isPhone() and Meteor.user()?.settings?.preferences?.saveMobileBandwidth
return false

return true
8 changes: 7 additions & 1 deletion server/methods/saveUserPreferences.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ Meteor.methods

if settings.convertAsciiEmoji?
preferences.convertAsciiEmoji = if settings.convertAsciiEmoji is "1" then true else false


if settings.saveMobileBandwidth?
preferences.saveMobileBandwidth = if settings.saveMobileBandwidth is "1" then true else false

if settings.autoImageLoad?
preferences.autoImageLoad = if settings.autoImageLoad is "1" then true else false

Meteor.users.update Meteor.userId(), { $set: { "settings.preferences": preferences } }

return true

0 comments on commit bc6f656

Please sign in to comment.