mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
reduce scanning overhead a bit
This commit is contained in:
parent
701b8540d8
commit
6ef4f0e449
1 changed files with 31 additions and 51 deletions
|
@ -949,19 +949,6 @@ var Dashboard = {
|
||||||
|
|
||||||
processLibraryUpdateNotification: function (data) {
|
processLibraryUpdateNotification: function (data) {
|
||||||
|
|
||||||
var newItems = data.ItemsAdded.filter(function (a) {
|
|
||||||
return !a.IsFolder;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!Dashboard.newItems) {
|
|
||||||
Dashboard.newItems = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0, length = newItems.length ; i < length; i++) {
|
|
||||||
|
|
||||||
Dashboard.newItems.push(newItems[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Dashboard.newItemTimeout) {
|
if (Dashboard.newItemTimeout) {
|
||||||
clearTimeout(Dashboard.newItemTimeout);
|
clearTimeout(Dashboard.newItemTimeout);
|
||||||
}
|
}
|
||||||
|
@ -971,52 +958,45 @@ var Dashboard = {
|
||||||
|
|
||||||
onNewItemTimerStopped: function () {
|
onNewItemTimerStopped: function () {
|
||||||
|
|
||||||
var newItems = Dashboard.newItems;
|
ApiClient.getItems(Dashboard.getCurrentUserId(), {
|
||||||
|
|
||||||
newItems = newItems.sort(function (a, b) {
|
Recursive: true,
|
||||||
|
Limit: 2,
|
||||||
|
Fitlers: "IsNotFolder",
|
||||||
|
SortBy: "DateCreated",
|
||||||
|
SortOrder: "Descending",
|
||||||
|
ImageTypes: "Primary"
|
||||||
|
|
||||||
if (a.PrimaryImageTag && b.PrimaryImageTag) {
|
}).done(function (result) {
|
||||||
return 0;
|
|
||||||
|
var items = result.Items;
|
||||||
|
|
||||||
|
for (var i = 0, length = Math.min(items.length, 2) ; i < length; i++) {
|
||||||
|
|
||||||
|
var item = items[i];
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
title: "New " + item.Type,
|
||||||
|
body: item.Name,
|
||||||
|
timeout: 5000
|
||||||
|
};
|
||||||
|
|
||||||
|
var imageTags = item.ImageTags || {};
|
||||||
|
|
||||||
|
if (imageTags.Primary) {
|
||||||
|
|
||||||
|
data.icon = ApiClient.getImageUrl(item.Id, {
|
||||||
|
width: 100,
|
||||||
|
tag: imageTags.Primary,
|
||||||
|
type: "Primary"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
WebNotifications.show(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.PrimaryImageTag) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Dashboard.newItems = [];
|
|
||||||
Dashboard.newItemTimeout = null;
|
Dashboard.newItemTimeout = null;
|
||||||
|
|
||||||
// Show at most 3 notifications
|
|
||||||
for (var i = 0, length = Math.min(newItems.length, 3) ; i < length; i++) {
|
|
||||||
|
|
||||||
var item = newItems[i];
|
|
||||||
|
|
||||||
var data = {
|
|
||||||
title: "New " + item.Type,
|
|
||||||
body: item.Name,
|
|
||||||
timeout: 6000
|
|
||||||
};
|
|
||||||
|
|
||||||
if (item.PrimaryImageTag) {
|
|
||||||
data.icon = ApiClient.getImageUrl(item.Id, {
|
|
||||||
width: 100,
|
|
||||||
tag: item.PrimaryImageTag,
|
|
||||||
type: "Primary"
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!item.Id || !data.icon || data.icon == "undefined") {
|
|
||||||
alert("bad image url: " + JSON.stringify(item));
|
|
||||||
console.log("bad image url: " + JSON.stringify(item));
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WebNotifications.show(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ensurePageTitle: function (page) {
|
ensurePageTitle: function (page) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue