mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
use common sharing manager
This commit is contained in:
parent
190f70bb71
commit
3657bdf7b7
10 changed files with 80 additions and 79 deletions
60
dashboard-ui/bower_components/emby-webcomponents/sharing/sharingmanager.js
vendored
Normal file
60
dashboard-ui/bower_components/emby-webcomponents/sharing/sharingmanager.js
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
define(['connectionManager', 'sharingMenu', 'loading'], function (connectionManager, sharingMenu, loading) {
|
||||
|
||||
function onSharingSuccess(options) {
|
||||
|
||||
console.log('share success. shareId: ' + options.share.Id);
|
||||
}
|
||||
|
||||
function onSharingCancel(options, apiClient) {
|
||||
|
||||
var shareId = options.share.Id;
|
||||
|
||||
console.log('share cancelled. shareId: ' + shareId);
|
||||
|
||||
// Delete the share since it was cancelled
|
||||
apiClient.ajax({
|
||||
|
||||
type: 'DELETE',
|
||||
url: apiClient.getUrl('Social/Shares/' + shareId)
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function showMenu(apiClient, itemId) {
|
||||
|
||||
loading.show();
|
||||
var userId = apiClient.getCurrentUserId();
|
||||
|
||||
return apiClient.getItem(userId, itemId).then(function () {
|
||||
|
||||
return apiClient.ajax({
|
||||
type: 'POST',
|
||||
url: apiClient.getUrl('Social/Shares', {
|
||||
|
||||
ItemId: itemId,
|
||||
UserId: userId
|
||||
}),
|
||||
dataType: "json"
|
||||
|
||||
}).then(function (share) {
|
||||
|
||||
var options = {
|
||||
share: share
|
||||
};
|
||||
|
||||
loading.hide();
|
||||
sharingMenu.showMenu(options, onSharingSuccess, function (options) {
|
||||
onSharingCancel(options, apiClient);
|
||||
});
|
||||
|
||||
}, function () {
|
||||
|
||||
loading.hide();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
showMenu: showMenu
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue