mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-13 12:00:01 -04:00
Don't fetch the data unless on the page
This commit is contained in:
parent
d2b05a1b1b
commit
a9b94c27d4
1 changed files with 16 additions and 10 deletions
|
@ -8,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="w-0 h-0 visibility-none hidden"> <asset-loader /> </div>
|
||||||
<script>
|
<script>
|
||||||
type Assets = {
|
type Assets = {
|
||||||
description: string,
|
description: string,
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
type: string,
|
type: string,
|
||||||
version: string
|
version: string
|
||||||
}
|
}
|
||||||
import { pageLoad } from "@utils/events";
|
|
||||||
import { Settings, settings } from "@utils/settings";
|
import { Settings, settings } from "@utils/settings";
|
||||||
async function getItem(item: any) {
|
async function getItem(item: any) {
|
||||||
try {
|
try {
|
||||||
|
@ -106,11 +105,18 @@
|
||||||
console.log(mainDiv);
|
console.log(mainDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
pageLoad(async () => {
|
//I don't actually want this to run on every page but defining a custom component is an easy way around it.
|
||||||
|
class AssetLoader extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
(async function() {
|
||||||
const mainElem = document.getElementById("main-theme");
|
const mainElem = document.getElementById("main-theme");
|
||||||
try { attachThemeEvent(mainElem!, true) } catch(_) {}
|
try { attachThemeEvent(mainElem!, true) } catch(_) {}
|
||||||
const assets = await getAssets();
|
const assets = await getAssets();
|
||||||
console.log(assets);
|
console.log(assets);
|
||||||
assets.map((asset) => { createElem(asset); });
|
assets.map((asset) => { createElem(asset); });
|
||||||
}, true);
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customElements.define('asset-loader', AssetLoader);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue