From 6e51215e48df5e0197214c7c9e50f8688ac619cc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 3 May 2013 00:10:11 -0400 Subject: [PATCH] fixes #223 - New Content Localhost Popups Repeat 'Old' 'New Content' on Media Changes --- dashboard-ui/scripts/site.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 28d70fc428..1d29c4974b 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -983,10 +983,20 @@ var Dashboard = { clearTimeout(Dashboard.newItemTimeout); } - Dashboard.newItemTimeout = setTimeout(Dashboard.onNewItemTimerStopped, 60000); + Dashboard.newItemTimeout = setTimeout(function() { + + Dashboard.onNewItemTimerStopped(data); + + }, 60000); }, - onNewItemTimerStopped: function () { + onNewItemTimerStopped: function (data) { + + var newItems = data.ItemsAdded; + + if (!newItems.length) { + return; + } ApiClient.getItems(Dashboard.getCurrentUserId(), { @@ -995,7 +1005,8 @@ var Dashboard = { Filters: "IsNotFolder", SortBy: "DateCreated", SortOrder: "Descending", - ImageTypes: "Primary" + ImageTypes: "Primary", + Ids: newItems.join(',') }).done(function (result) { @@ -1005,7 +1016,7 @@ var Dashboard = { var item = items[i]; - var data = { + var notification = { title: "New " + item.Type, body: item.Name, timeout: 5000 @@ -1015,14 +1026,14 @@ var Dashboard = { if (imageTags.Primary) { - data.icon = ApiClient.getImageUrl(item.Id, { + notification.icon = ApiClient.getImageUrl(item.Id, { width: 100, tag: imageTags.Primary, type: "Primary" }); } - WebNotifications.show(data); + WebNotifications.show(notification); } });