Skip to content

Commit

Permalink
Remove MetadataEditor global
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed Feb 13, 2025
1 parent 8cc88fb commit 9c6ea4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ module.exports = {
'Emby': 'readonly',
'Hls': 'writable',
'LibraryMenu': 'writable',
'MetadataEditor': 'writable',
'Windows': 'readonly',
// Build time definitions
__COMMIT_SHA__: 'readonly',
Expand Down
14 changes: 8 additions & 6 deletions src/controllers/edititemmetadata.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import loading from '../components/loading/loading';
import '../scripts/editorsidebar';
import loading from 'components/loading/loading';
import { getCurrentItemId, setCurrentItemId } from 'scripts/editorsidebar';

function reload(context, itemId) {
loading.show();
Expand All @@ -16,14 +16,16 @@ function reload(context, itemId) {

export default function (view) {
view.addEventListener('viewshow', function () {
reload(this, MetadataEditor.getCurrentItemId());
reload(this, getCurrentItemId());
});
MetadataEditor.setCurrentItemId(null);

setCurrentItemId(null);

view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
const data = event.detail;

if (data.id != MetadataEditor.getCurrentItemId()) {
MetadataEditor.setCurrentItemId(data.id);
if (data.id != getCurrentItemId()) {
setCurrentItemId(data.id);
reload(view, data.id);
}
});
Expand Down
17 changes: 3 additions & 14 deletions src/scripts/editorsidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,12 @@ function updateEditorNode(page, item) {
}
}

function setCurrentItemId(id) {
let itemId;
export function setCurrentItemId(id) {
itemId = id;
}

function getCurrentItemId() {
export function getCurrentItemId() {
if (itemId) {
return itemId;
}
Expand Down Expand Up @@ -326,16 +327,4 @@ $(document).on('itemsaved', '.metadataEditorPage', function (e, item) {
.off('open_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 */

0 comments on commit 9c6ea4b

Please sign in to comment.