(js) Improve $scope.$watch
parent
cebd79a66e
commit
77ce13967c
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
// Wait on user's defaults
|
// Wait on user's defaults
|
||||||
Preferences.ready().then(function() {
|
Preferences.ready().then(function() {
|
||||||
$scope.$watch('vm.email', function(email, old) {
|
$scope.$watch(function() { return vm.email; }, function(email, old) {
|
||||||
if (email && vm.urlEmail != email) {
|
if (email && vm.urlEmail != email) {
|
||||||
// Email has changed or doesn't match the current URL (this happens when using md-virtual-repeat)
|
// Email has changed or doesn't match the current URL (this happens when using md-virtual-repeat)
|
||||||
showGenericAvatar();
|
showGenericAvatar();
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
// If sg-src is defined, watch the expression for the URL of a local image
|
// If sg-src is defined, watch the expression for the URL of a local image
|
||||||
if ('sg-src' in $element[0].attributes) {
|
if ('sg-src' in $element[0].attributes) {
|
||||||
$scope.$watch('vm.src', function(src) {
|
$scope.$watch(function() { return vm.src; }, function(src) {
|
||||||
if (src) {
|
if (src) {
|
||||||
// Set image URL and save the associated email address
|
// Set image URL and save the associated email address
|
||||||
vm.url = src;
|
vm.url = src;
|
||||||
|
|
|
@ -42,19 +42,20 @@
|
||||||
// One-way refresh of the parent window when modifying the message from a popup window.
|
// One-way refresh of the parent window when modifying the message from a popup window.
|
||||||
if ($window.opener) {
|
if ($window.opener) {
|
||||||
// Update the message flags. The message must be displayed in the parent window.
|
// Update the message flags. The message must be displayed in the parent window.
|
||||||
$scope.$watchCollection('viewer.message.flags', function(newTags, oldTags) {
|
$scope.$watchCollection(function() { return vm.message.flags; }, function(newTags, oldTags) {
|
||||||
var ctrls;
|
var ctrls;
|
||||||
if (newTags || oldTags) {
|
if (newTags || oldTags) {
|
||||||
ctrls = $parentControllers();
|
ctrls = $parentControllers();
|
||||||
if (ctrls.messageCtrl) {
|
if (ctrls.messageCtrl) {
|
||||||
ctrls.messageCtrl.service.$timeout(function() {
|
ctrls.messageCtrl.service.$timeout(function() {
|
||||||
|
ctrls.messageCtrl.showFlags = true;
|
||||||
ctrls.messageCtrl.message.flags = newTags;
|
ctrls.messageCtrl.message.flags = newTags;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Update the "isflagged" (star icon) of the message. The mailbox must be displayed in the parent window.
|
// Update the "isflagged" (star icon) of the message. The mailbox must be displayed in the parent window.
|
||||||
$scope.$watch('viewer.message.isflagged', function(isflagged, wasflagged) {
|
$scope.$watch(function() { return vm.message.isflagged; }, function(isflagged, wasflagged) {
|
||||||
var ctrls = $parentControllers();
|
var ctrls = $parentControllers();
|
||||||
if (ctrls.mailboxCtrl) {
|
if (ctrls.mailboxCtrl) {
|
||||||
ctrls.mailboxCtrl.service.$timeout(function() {
|
ctrls.mailboxCtrl.service.$timeout(function() {
|
||||||
|
@ -67,7 +68,7 @@
|
||||||
else {
|
else {
|
||||||
// Flatten new tags when coming from the predefined list of tags (Message.$tags) and
|
// Flatten new tags when coming from the predefined list of tags (Message.$tags) and
|
||||||
// sync tags with server when adding or removing a tag.
|
// sync tags with server when adding or removing a tag.
|
||||||
$scope.$watchCollection('viewer.message.flags', function(_newTags, _oldTags) {
|
$scope.$watchCollection(function() { return vm.message.flags; }, function(_newTags, _oldTags) {
|
||||||
var newTags, oldTags, tags;
|
var newTags, oldTags, tags;
|
||||||
if (_newTags || _oldTags) {
|
if (_newTags || _oldTags) {
|
||||||
newTags = _newTags || [];
|
newTags = _newTags || [];
|
||||||
|
|
|
@ -348,7 +348,7 @@
|
||||||
vm.saveProperties = saveProperties;
|
vm.saveProperties = saveProperties;
|
||||||
vm.close = close;
|
vm.close = close;
|
||||||
|
|
||||||
$scope.$watch('properties.calendar.color', function() {
|
$scope.$watch(function() { return vm.calendar.color; }, function() {
|
||||||
srcCalendar.color = vm.calendar.color;
|
srcCalendar.color = vm.calendar.color;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue