Add version number to home drawer

This commit is contained in:
Jade Macho 2024-05-14 18:52:36 +02:00
parent d6b84ce2cc
commit e7b42dbbf1
Signed by: 0x0ade
GPG Key ID: E1960710FE4FBEEF
4 changed files with 56 additions and 22 deletions

View File

@ -9,6 +9,7 @@ import JadefinUtils from "./JadefinUtils.js";
export default JadefinIntegrity("Jadefin", import.meta.url, () => window["Jadefin"] = new (class Jadefin extends JadefinMod {
modUrl = import.meta.url;
root = this.modUrl.substring(0, this.modUrl.lastIndexOf("/"));
version = this.root.substring(this.root.lastIndexOf("/") + 1);
/** @type {{[id: string]: JadefinMod}} */
mods = {};

View File

@ -237,4 +237,12 @@ export default JadefinIntegrity("JadefinModules", import.meta.url, () => window[
return this._.events ??= this.Jadefin.findWebpackRawLoad(e => e.Events?.on && e.Events?.off && e.Events?.trigger && 1)[0]?.Events;
}
// index.jsx
/**
@return {any}
*/
get index() {
return this._.index ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o._minServerVersion))[0];
}
})());

View File

@ -12,3 +12,11 @@
pointer-events: none;
opacity: 0.5;
}
.extrasVersion {
cursor: default;
user-select: none;
line-height: 2em;
opacity: 0.5;
font-size: 0.8em;
}

View File

@ -2,6 +2,7 @@
import JadefinIntegrity from '../JadefinIntegrity.js';
import Jadefin from "../Jadefin.js";
import JadefinMod from "../JadefinMod.js";
import JadefinModules from "../JadefinModules.js";
import JadefinUtils from "../JadefinUtils.js";
@ -48,6 +49,13 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class
</div>
`;
drawerVersionEl = rd$()`
<div class="sidebarHeader extrasVersion">
Jellyfin <span id="extrasVersionJellyfin"></span><br>
Jadefin <span id="extrasVersionJadefin"></span>
</div>
`;
constructor() {
super();
@ -106,6 +114,17 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class
}
drawer?.insertBefore(this.drawerExtrasEl, userMenuOptions);
drawer?.appendChild(this.drawerVersionEl);
const versionJellyfinEl = this.drawerVersionEl.querySelector("#extrasVersionJellyfin");
if (versionJellyfinEl) {
versionJellyfinEl.textContent = JadefinModules.ApiClient.appVersion();
}
const versionJadefinEl = this.drawerVersionEl.querySelector("#extrasVersionJadefin");
if (versionJadefinEl) {
versionJadefinEl.textContent = Jadefin.version;
}
this.update();
}
@ -159,7 +178,6 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class
}
update() {
if (this.drawerExtrasEl) {
this.drawerExtrasEl.innerHTML = `<h3 class="sidebarHeader">Extras</h3>`;
for (let item of this._items) {
@ -184,7 +202,6 @@ export default JadefinIntegrity("ExtrasMenu", import.meta.url, () => new (class
this.drawerExtrasEl.appendChild(itemEl);
}
}
}
/**
* @param {number} current