From fc14eec7ebbbba1f1bce637993da097df36630e9 Mon Sep 17 00:00:00 2001 From: CenTdemeern1 Date: Tue, 14 Jan 2025 15:41:31 +0100 Subject: [PATCH] The last few tweaks that were needed to make this work --- static/crossroad.mts | 11 +++++++---- static/storage_manager.mts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/static/crossroad.mts b/static/crossroad.mts index 03e5a8c..852b3e0 100644 --- a/static/crossroad.mts +++ b/static/crossroad.mts @@ -1,7 +1,7 @@ import { initializeAddInstanceDialog } from "./add_an_instance.mjs"; import { initializeInstanceDetailsDialog } from "./confirm_instance_details.mjs"; import knownSoftware from "./known_software.mjs"; -import storageManager from "./storage_manager.mjs"; +import storageManager, { Instance } from "./storage_manager.mjs"; console.log(knownSoftware); console.log(storageManager.storage.instances); @@ -17,12 +17,15 @@ const instanceDetailsDialogCallback = ( software: string, icon: string | null ) => { - storageManager.storage.instances.push({ + const instance: Instance = { name, origin: `http${hostSecure ? "s" : ""}://${host}`, software, iconURL: icon ?? undefined - }); + }; + storageManager.storage.instances.push(instance); + storageManager.save(); + console.log("Successfully added new instance:", instance); }; const detailsDialog = document.querySelector("#instanceDetails"); @@ -42,7 +45,7 @@ const addInstanceDialogCallback = async ( try { if (!autoQueryMetadata) throw new Error("Don't"); const { name, software, iconURL } = - await fetch(`/api/instance_info/${secure}/${encodeURI(host)}`) + await fetch(`/api/instance_info/${secure}/${encodeURIComponent(host)}`) .then(r => r.json()); if ( typeof name !== "string" diff --git a/static/storage_manager.mts b/static/storage_manager.mts index 0f22bbb..da88774 100644 --- a/static/storage_manager.mts +++ b/static/storage_manager.mts @@ -1,4 +1,4 @@ -type Instance = { +export type Instance = { /** * The instance's (nick)name * @example "eepy.moe"