From c4a348db67b0a11995d88c6752e5bd376271643b Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Sun, 13 May 2018 07:43:51 +0200 Subject: [PATCH 1/2] gui: Fallback to folder ID in recent changes (fixes #4947) (#4949) --- gui/default/syncthing/device/globalChangesModalView.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/default/syncthing/device/globalChangesModalView.html b/gui/default/syncthing/device/globalChangesModalView.html index 60a8960b..28a65023 100644 --- a/gui/default/syncthing/device/globalChangesModalView.html +++ b/gui/default/syncthing/device/globalChangesModalView.html @@ -19,7 +19,7 @@ Unknown {{changeEvent.data.action}} {{changeEvent.data.type}} - {{changeEvent.data.label}} + {{folderLabel(changeEvent.data.folder)}} {{changeEvent.data.path}} {{changeEvent.time | date:"yyyy-MM-dd HH:mm:ss"}} From 92602485434d17b473b2034b4291d29d869c4076 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 13 May 2018 07:44:19 +0200 Subject: [PATCH 2/2] gui: Fix scopes in notification directive (fixes #4941) (#4948) The directive lives in its own isolated scope (where we put the visible() function). The stuff transcluded into the notification directive lives in the root scope and doesn't have access to the directive scope. Hence we cannot call dismiss() from inside the directive. Similarly, config does not exist by itself in the directive scope, we need $parent to access the root scope. Reference: https://docs.angularjs.org/guide/directive#isolating-the-scope-of-a-directive How this worked before is a mystery. My guess is Angular bug with directive scope that was fixed in 1.3. One possibility is that transclude plus scope: true (which doesn't make sense as that is supposed to be an object) resulted in the root scope being used in the directive itself. This would then "work" as long as there is only one notification, as visible() and dismiss() would then be registered on the root scope, thus accessible from within the notification but also overridden by any notification rendered. --- gui/default/syncthing/core/notificationDirective.js | 13 +++---------- gui/default/syncthing/core/notifications.html | 10 +++++----- gui/default/syncthing/core/syncthingController.js | 8 ++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gui/default/syncthing/core/notificationDirective.js b/gui/default/syncthing/core/notificationDirective.js index fc7810f6..e3a4dd24 100644 --- a/gui/default/syncthing/core/notificationDirective.js +++ b/gui/default/syncthing/core/notificationDirective.js @@ -2,20 +2,13 @@ angular.module('syncthing.core') .directive('notification', function () { return { restrict: 'E', - scope: true, + scope: {}, transclude: true, template: '
', link: function (scope, elm, attrs) { scope.visible = function () { - return scope.config.options.unackedNotificationIDs.indexOf(attrs.id) > -1; - } - scope.dismiss = function () { - var idx = scope.config.options.unackedNotificationIDs.indexOf(attrs.id); - if (idx > -1) { - scope.config.options.unackedNotificationIDs.splice(idx, 1); - scope.saveConfig(); - } - } + return scope.$parent.config.options.unackedNotificationIDs.indexOf(attrs.id) > -1; + }; } }; }); diff --git a/gui/default/syncthing/core/notifications.html b/gui/default/syncthing/core/notifications.html index 34b437a7..55987ab8 100644 --- a/gui/default/syncthing/core/notifications.html +++ b/gui/default/syncthing/core/notifications.html @@ -6,7 +6,7 @@

This is an example notification. ID of the notification should be appended to Options.UnackedNotificationIDs of the config.