Browse Source

Merge branch 'pr/714'

master
Igor Zhukov 10 years ago
parent
commit
424edd56e4
  1. 14
      app/js/controllers.js
  2. 2
      app/js/locales/en-us.json
  3. 14
      app/js/services.js
  4. 5
      app/partials/desktop/settings_modal.html
  5. 7
      app/partials/mobile/settings_modal.html

14
app/js/controllers.js

@ -2549,7 +2549,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}); });
}; };
Storage.get('notify_nodesktop', 'notify_nosound', 'send_ctrlenter', 'notify_volume', 'notify_novibrate').then(function (settings) { Storage.get('notify_nodesktop', 'notify_nosound', 'send_ctrlenter', 'notify_volume', 'notify_novibrate', 'notify_nopreview').then(function (settings) {
$scope.notify.desktop = !settings[0]; $scope.notify.desktop = !settings[0];
$scope.send.enter = settings[2] ? '' : '1'; $scope.send.enter = settings[2] ? '' : '1';
@ -2564,6 +2564,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.notify.canVibrate = NotificationsManager.getVibrateSupport(); $scope.notify.canVibrate = NotificationsManager.getVibrateSupport();
$scope.notify.vibrate = !settings[4]; $scope.notify.vibrate = !settings[4];
$scope.notify.preview = !settings[5];
$scope.notify.volumeOf4 = function () { $scope.notify.volumeOf4 = function () {
return 1 + Math.ceil(($scope.notify.volume - 0.1) / 0.33); return 1 + Math.ceil(($scope.notify.volume - 0.1) / 0.33);
}; };
@ -2602,6 +2604,16 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
} }
$scope.togglePreview = function () {
$scope.notify.preview = !$scope.notify.preview;
if ($scope.notify.preview) {
Storage.remove('notify_nopreview');
} else {
Storage.set({notify_nopreview: true});
}
}
$scope.toggleVibrate = function () { $scope.toggleVibrate = function () {
$scope.notify.vibrate = !$scope.notify.vibrate; $scope.notify.vibrate = !$scope.notify.vibrate;

2
app/js/locales/en-us.json

@ -43,6 +43,7 @@
"settings_modal_sounds": "Sounds", "settings_modal_sounds": "Sounds",
"settings_modal_language": "Language", "settings_modal_language": "Language",
"settings_modal_notifications": "Desktop notifications", "settings_modal_notifications": "Desktop notifications",
"settings_modal_message_preview": "Message Preview",
"settings_modal_sound": "Sound", "settings_modal_sound": "Sound",
"settings_modal_enter_send_description_md": "**Enter** - send message, **Shift + Enter** - new line", "settings_modal_enter_send_description_md": "**Enter** - send message, **Shift + Enter** - new line",
"settings_modal_ctrl_enter_send_description_md": "**Ctrl + Enter** - send message, **Enter** - new line", "settings_modal_ctrl_enter_send_description_md": "**Ctrl + Enter** - send message, **Enter** - new line",
@ -206,6 +207,7 @@
"conversation_kicked_user": "removed {user}", "conversation_kicked_user": "removed {user}",
"conversation_invited_user_message": "invited user", "conversation_invited_user_message": "invited user",
"conversation_kicked_user_message": "removed user", "conversation_kicked_user_message": "removed user",
"conversation_message_sent": "sent you a message",
"conversation_unknown_user": "Somebody", "conversation_unknown_user": "Somebody",
"conversation_unknown_chat": "Unknown chat", "conversation_unknown_chat": "Unknown chat",

14
app/js/services.js

@ -889,7 +889,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (message.unread && !message.out) { if (message.unread && !message.out) {
NotificationsManager.getPeerMuted(peerID).then(function (muted) { NotificationsManager.getPeerMuted(peerID).then(function (muted) {
if (!muted) { if (!muted) {
notifyAboutMessage(message); Storage.get('notify_nopreview').then(function (no_preview) {
notifyAboutMessage(message, no_preview);
});
} }
}); });
} }
@ -2040,7 +2042,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
} }
function notifyAboutMessage (message) { function notifyAboutMessage (message, no_preview) {
var peerID = getMessagePeer(message); var peerID = getMessagePeer(message);
var fromUser = AppUsersManager.getUser(message.from_id); var fromUser = AppUsersManager.getUser(message.from_id);
var fromPhoto = AppUsersManager.getUserPhoto(message.from_id, 'User'); var fromPhoto = AppUsersManager.getUserPhoto(message.from_id, 'User');
@ -2050,7 +2052,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
notificationPhoto; notificationPhoto;
if (message.message) { if (message.message) {
if (no_preview) {
notificationMessage = _('conversation_message_sent');
} else {
notificationMessage = RichTextProcessor.wrapPlainText(message.message); notificationMessage = RichTextProcessor.wrapPlainText(message.message);
}
} else if (message.media) { } else if (message.media) {
switch (message.media._) { switch (message.media._) {
case 'messageMediaPhoto': notificationMessage = _('conversation_media_photo_raw'); break; case 'messageMediaPhoto': notificationMessage = _('conversation_media_photo_raw'); break;
@ -2239,7 +2245,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
setTimeout(function () { setTimeout(function () {
isMutedPromise.then(function (muted) { isMutedPromise.then(function (muted) {
if (message.unread && !muted) { if (message.unread && !muted) {
notifyAboutMessage(message); Storage.get('notify_nopreview').then(function (no_preview) {
notifyAboutMessage(message, no_preview);
});
} }
}) })
}, timeout); }, timeout);

5
app/partials/desktop/settings_modal.html

@ -61,6 +61,11 @@
<span class="tg_checkbox_label" my-i18n="settings_modal_notifications"></span> <span class="tg_checkbox_label" my-i18n="settings_modal_notifications"></span>
</a> </a>
<a class="md_modal_section_toggle_wrap tg_checkbox" ng-click="togglePreview()" ng-class="notify.preview ? 'tg_checkbox_on' : ''">
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>
<span class="tg_checkbox_label" my-i18n="settings_modal_message_preview"></span>
</a>
<a class="md_modal_section_toggle_wrap tg_checkbox" ng-click="toggleSound()" ng-class="notify.volume ? 'tg_checkbox_on' : ''"> <a class="md_modal_section_toggle_wrap tg_checkbox" ng-click="toggleSound()" ng-class="notify.volume ? 'tg_checkbox_on' : ''">
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span> <span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>
<span class="tg_checkbox_label" my-i18n="settings_modal_sound"></span> <span class="tg_checkbox_label" my-i18n="settings_modal_sound"></span>

7
app/partials/mobile/settings_modal.html

@ -83,6 +83,13 @@
</a> </a>
</div> </div>
<div class="mobile_modal_action_wrap">
<a class="mobile_modal_action tg_checkbox clearfix" ng-click="togglePreview()" ng-class="notify.preview ? 'tg_checkbox_on' : ''">
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>
<span class="tg_checkbox_label" my-i18n="settings_modal_message_preview"></span>
</a>
</div>
<div class="mobile_modal_action_wrap" ng-if="!notify.desktop &amp;&amp; notify.canVibrate"> <div class="mobile_modal_action_wrap" ng-if="!notify.desktop &amp;&amp; notify.canVibrate">
<a class="mobile_modal_action tg_checkbox clearfix" ng-click="toggleVibrate()" ng-class="notify.vibrate ? 'tg_checkbox_on' : ''"> <a class="mobile_modal_action tg_checkbox clearfix" ng-click="toggleVibrate()" ng-class="notify.vibrate ? 'tg_checkbox_on' : ''">
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span> <span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>

Loading…
Cancel
Save