1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Remove MetadataEditor global

This commit is contained in:
Bill Thornton 2025-02-13 16:13:38 -05:00
parent 8cc88fb08c
commit 9c6ea4b525
3 changed files with 11 additions and 21 deletions

View file

@ -249,7 +249,6 @@ module.exports = {
'Emby': 'readonly', 'Emby': 'readonly',
'Hls': 'writable', 'Hls': 'writable',
'LibraryMenu': 'writable', 'LibraryMenu': 'writable',
'MetadataEditor': 'writable',
'Windows': 'readonly', 'Windows': 'readonly',
// Build time definitions // Build time definitions
__COMMIT_SHA__: 'readonly', __COMMIT_SHA__: 'readonly',

View file

@ -1,5 +1,5 @@
import loading from '../components/loading/loading'; import loading from 'components/loading/loading';
import '../scripts/editorsidebar'; import { getCurrentItemId, setCurrentItemId } from 'scripts/editorsidebar';
function reload(context, itemId) { function reload(context, itemId) {
loading.show(); loading.show();
@ -16,14 +16,16 @@ function reload(context, itemId) {
export default function (view) { export default function (view) {
view.addEventListener('viewshow', function () { view.addEventListener('viewshow', function () {
reload(this, MetadataEditor.getCurrentItemId()); reload(this, getCurrentItemId());
}); });
MetadataEditor.setCurrentItemId(null);
setCurrentItemId(null);
view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) { view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
const data = event.detail; const data = event.detail;
if (data.id != MetadataEditor.getCurrentItemId()) { if (data.id != getCurrentItemId()) {
MetadataEditor.setCurrentItemId(data.id); setCurrentItemId(data.id);
reload(view, data.id); reload(view, data.id);
} }
}); });

View file

@ -287,11 +287,12 @@ function updateEditorNode(page, item) {
} }
} }
function setCurrentItemId(id) { let itemId;
export function setCurrentItemId(id) {
itemId = id; itemId = id;
} }
function getCurrentItemId() { export function getCurrentItemId() {
if (itemId) { if (itemId) {
return itemId; return itemId;
} }
@ -326,16 +327,4 @@ $(document).on('itemsaved', '.metadataEditorPage', function (e, item) {
.off('open_node.jstree', onNodeOpen) .off('open_node.jstree', onNodeOpen)
.off('load_node.jstree', onNodeOpen); .off('load_node.jstree', onNodeOpen);
}); });
let itemId;
window.MetadataEditor = {
getItemPromise: function () {
const currentItemId = getCurrentItemId();
if (currentItemId) {
return ApiClient.getItem(Dashboard.getCurrentUserId(), currentItemId);
}
return ApiClient.getRootFolder(Dashboard.getCurrentUserId());
},
getCurrentItemId: getCurrentItemId,
setCurrentItemId: setCurrentItemId
};
/* eslint-enable @typescript-eslint/naming-convention */ /* eslint-enable @typescript-eslint/naming-convention */