mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
switch to unified notifications
This commit is contained in:
parent
fa438393af
commit
cec6b66c27
19 changed files with 200 additions and 514 deletions
|
@ -15,12 +15,12 @@
|
|||
},
|
||||
"devDependencies": {},
|
||||
"ignore": [],
|
||||
"version": "1.4.113",
|
||||
"_release": "1.4.113",
|
||||
"version": "1.4.114",
|
||||
"_release": "1.4.114",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "1.4.113",
|
||||
"commit": "03c34e718b6b72ec847567dcedb114e32ff8a1f0"
|
||||
"tag": "1.4.114",
|
||||
"commit": "cf5d4390c6b08e025aaa3d7086172c483bc440ed"
|
||||
},
|
||||
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
|
||||
"_target": "^1.2.0",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focusManager'], function (connectionManager, playbackManager, events, inputManager, focusManager) {
|
||||
define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focusManager', 'embyRouter'], function (connectionManager, playbackManager, events, inputManager, focusManager, embyRouter) {
|
||||
|
||||
function displayMessage(cmd) {
|
||||
|
||||
|
@ -18,7 +18,14 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
|
|||
}
|
||||
}
|
||||
|
||||
function processGeneralCommand(cmd) {
|
||||
function displayContent(cmd, apiClient) {
|
||||
|
||||
apiClient.getItem(apiClient.getCurrentUserId(), cmd.ItemId).then(function (item) {
|
||||
embyRouter.showItem(item);
|
||||
});
|
||||
}
|
||||
|
||||
function processGeneralCommand(cmd, apiClient) {
|
||||
|
||||
// Full list
|
||||
// https://github.com/MediaBrowser/MediaBrowser/blob/master/MediaBrowser.Model/Session/GeneralCommand.cs#L23
|
||||
|
@ -93,7 +100,7 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
|
|||
inputManager.trigger('settings');
|
||||
break;
|
||||
case 'DisplayContent':
|
||||
//Dashboard.onBrowseCommand(cmd.Arguments);
|
||||
displayContent(cmd, apiClient);
|
||||
break;
|
||||
case 'GoToSearch':
|
||||
inputManager.trigger('search');
|
||||
|
@ -164,7 +171,7 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
|
|||
}
|
||||
else if (msg.MessageType === "GeneralCommand") {
|
||||
var cmd = msg.Data;
|
||||
processGeneralCommand(cmd);
|
||||
processGeneralCommand(cmd, apiClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,10 +181,10 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
|
|||
events.on(apiClient, "websocketmessage", onWebSocketMessageReceived);
|
||||
}
|
||||
|
||||
//var current = connectionManager.currentApiClient();
|
||||
//if (current) {
|
||||
// bindEvents(current);
|
||||
//}
|
||||
var current = connectionManager.currentApiClient();
|
||||
if (current) {
|
||||
bindEvents(current);
|
||||
}
|
||||
|
||||
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
|
||||
|
||||
|
|
|
@ -116,17 +116,13 @@ define(['playbackManager', 'focusManager', 'embyRouter'], function (playbackMana
|
|||
// TODO
|
||||
break;
|
||||
case 'next':
|
||||
if (playbackManager.isPlayingVideo()) {
|
||||
playbackManager.nextChapter();
|
||||
} else if (playbackManager.isPlaying()) {
|
||||
if (playbackManager.isPlaying()) {
|
||||
playbackManager.nextTrack();
|
||||
}
|
||||
break;
|
||||
case 'previous':
|
||||
|
||||
if (playbackManager.isPlayingVideo()) {
|
||||
playbackManager.previousChapter();
|
||||
} else if (playbackManager.isPlaying()) {
|
||||
if (playbackManager.isPlaying()) {
|
||||
playbackManager.previousTrack();
|
||||
}
|
||||
break;
|
||||
|
|
117
dashboard-ui/bower_components/emby-webcomponents/librarychangednotifications.js
vendored
Normal file
117
dashboard-ui/bower_components/emby-webcomponents/librarychangednotifications.js
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focusManager', 'embyRouter'], function (connectionManager, playbackManager, events, inputManager, focusManager, embyRouter) {
|
||||
|
||||
function onOneDocumentClick() {
|
||||
|
||||
document.removeEventListener('click', onOneDocumentClick);
|
||||
document.removeEventListener('keydown', onOneDocumentClick);
|
||||
|
||||
if (window.Notification) {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
}
|
||||
document.addEventListener('click', onOneDocumentClick);
|
||||
document.addEventListener('keydown', onOneDocumentClick);
|
||||
|
||||
function onLibraryChanged(data, apiClient) {
|
||||
|
||||
var newItems = data.ItemsAdded;
|
||||
|
||||
if (!newItems.length || /*AppInfo.isNativeApp ||*/ !window.Notification || Notification.permission !== "granted") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playbackManager.isPlayingVideo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
apiClient.getItems(apiClient.getCurrentUserId(), {
|
||||
|
||||
Recursive: true,
|
||||
Limit: 3,
|
||||
IsFolder: false,
|
||||
SortBy: "DateCreated",
|
||||
SortOrder: "Descending",
|
||||
ImageTypes: "Primary",
|
||||
Ids: newItems.join(',')
|
||||
|
||||
}).then(function (result) {
|
||||
|
||||
var items = result.Items;
|
||||
|
||||
for (var i = 0, length = items.length ; i < length; i++) {
|
||||
|
||||
var item = items[i];
|
||||
|
||||
var notification = {
|
||||
title: "New " + item.Type,
|
||||
body: item.Name,
|
||||
timeout: 15000,
|
||||
vibrate: true,
|
||||
|
||||
data: {
|
||||
//options: {
|
||||
// url: LibraryBrowser.getHref(item)
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
var imageTags = item.ImageTags || {};
|
||||
|
||||
if (imageTags.Primary) {
|
||||
|
||||
notification.icon = apiClient.getScaledImageUrl(item.Id, {
|
||||
width: 80,
|
||||
tag: imageTags.Primary,
|
||||
type: "Primary"
|
||||
});
|
||||
}
|
||||
|
||||
var notif = new Notification(notification.title, notification);
|
||||
|
||||
if (notif.show) {
|
||||
notif.show();
|
||||
}
|
||||
|
||||
if (notification.timeout) {
|
||||
setTimeout(function () {
|
||||
|
||||
if (notif.close) {
|
||||
notif.close();
|
||||
}
|
||||
else if (notif.cancel) {
|
||||
notif.cancel();
|
||||
}
|
||||
}, notification.timeout);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onWebSocketMessageReceived(e, msg) {
|
||||
|
||||
var apiClient = this;
|
||||
|
||||
if (msg.MessageType === "LibraryChanged") {
|
||||
var cmd = msg.Data;
|
||||
onLibraryChanged(cmd, apiClient);
|
||||
}
|
||||
}
|
||||
|
||||
function bindEvents(apiClient) {
|
||||
|
||||
if (!apiClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
events.off(apiClient, "websocketmessage", onWebSocketMessageReceived);
|
||||
events.on(apiClient, "websocketmessage", onWebSocketMessageReceived);
|
||||
}
|
||||
|
||||
bindEvents(connectionManager.currentApiClient());
|
||||
|
||||
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
|
||||
|
||||
bindEvents(newApiClient);
|
||||
});
|
||||
|
||||
});
|
|
@ -29,14 +29,14 @@
|
|||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"ignore": [],
|
||||
"homepage": "https://github.com/polymerelements/iron-behaviors",
|
||||
"homepage": "https://github.com/PolymerElements/iron-behaviors",
|
||||
"_release": "1.0.17",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.17",
|
||||
"commit": "ef8e89b5f0aa4e8a6b51ca6491ea453bf395f94f"
|
||||
},
|
||||
"_source": "git://github.com/polymerelements/iron-behaviors.git",
|
||||
"_source": "git://github.com/PolymerElements/iron-behaviors.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "polymerelements/iron-behaviors"
|
||||
"_originalSource": "PolymerElements/iron-behaviors"
|
||||
}
|
|
@ -31,14 +31,14 @@
|
|||
"web-component-tester": "*"
|
||||
},
|
||||
"private": true,
|
||||
"homepage": "https://github.com/Polymer/polymer",
|
||||
"homepage": "https://github.com/polymer/polymer",
|
||||
"_release": "1.6.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.6.0",
|
||||
"commit": "8715c83bf04a228de00ec662ed43eb6141e61b91"
|
||||
},
|
||||
"_source": "git://github.com/Polymer/polymer.git",
|
||||
"_source": "git://github.com/polymer/polymer.git",
|
||||
"_target": "^1.1.0",
|
||||
"_originalSource": "Polymer/polymer"
|
||||
"_originalSource": "polymer/polymer"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue