fix: 🐛 aquabox

pull/99/head
Raymond 2025-01-04 22:30:40 -05:00
parent 8b9236ae43
commit d220f369e9
4 changed files with 23 additions and 12 deletions

View File

@ -141,8 +141,12 @@
indexedDB.databases().then(async (dbi) => {
let databaseExists = dbi.some(db => db.name == "userboxChusanDDS");
if (databaseExists)
if (USERBOX_URL_STATE.value && databaseExists) {
indexedDB.deleteDatabase("userboxChusanDDS")
}
if (databaseExists) {
await initializeDb();
}
if (databaseExists || USERBOX_URL_STATE.value) {
DDSreader = new DDS(ddsDB);
USERBOX_INSTALLED = databaseExists || USERBOX_URL_STATE.value != "";
@ -283,26 +287,28 @@
{#if USERBOX_SETUP_MODE}
<input type="text" on:keyup={e => {if (e.key == "Enter") userboxHandleInput((e.target as HTMLInputElement).value)}} class="add-margin" placeholder="Base URL">
{:else}
<p class="notice add-margin">
{t('userbox.new.setup.notice')}
</p>
{#if USERBOX_PROGRESS != 0}
<div class="progress">
<div class="progress-bar" style="width: {USERBOX_PROGRESS}%"></div>
</div>
{:else}
<p class="notice add-margin">
{t('userbox.new.setup.notice')}
</p>
<button class="drop-btn">
<input type="file" on:input={userboxSafeDrop} on:click={e => e.preventDefault()}>
{t('userbox.new.drop')}
</button>
{/if}
{/if}
<button on:click={() => USERBOX_SETUP_RUN = false}>
{t('back')}
</button>
<button on:click={() => USERBOX_SETUP_MODE = !USERBOX_SETUP_MODE}>
{t(USERBOX_SETUP_MODE ? 'userbox.new.switch.to_drop' : 'userbox.new.switch.to_url')}
</button>
{#if USERBOX_PROGRESS == 0}
<button on:click={() => USERBOX_SETUP_RUN = false}>
{t('back')}
</button>
<button on:click={() => USERBOX_SETUP_MODE = !USERBOX_SETUP_MODE}>
{t(USERBOX_SETUP_MODE ? 'userbox.new.switch.to_drop' : 'userbox.new.switch.to_url')}
</button>
{/if}
</div>
</div>
</div>

View File

@ -11,6 +11,10 @@
export var chuniCharacter: number = 0
export var chuniTrophyName: string = "NEWCOMER"
export var chuniIsUserbox: boolean = false;
let ratingToString = (rating: number) => {
return rating.toFixed(2)
}
</script>
{#await DDSreader?.getFile(`nameplate:${chuniNameplate.toString().padStart(8, "0")}`, `nameplate:00000001`) then nameplateURL}
<!-- svelte-ignore a11y_click_events_have_key_events -->
@ -40,7 +44,7 @@
<div class="chuni-user-rating">
RATING
<span class="chuni-user-rating-number">
{chuniRating}
{ratingToString(chuniRating)}
</span>
</div>
</div>

View File

@ -47,7 +47,7 @@ export default class DDSCache {
*/
getFromDatabase(path: string): Promise<Blob | null> {
return new Promise(async (resolve, reject) => {
if (this.userboxURL.value) {
if (this.userboxURL.value != "") {
let targetPath = path.replaceAll(":", "/");
let response = await fetch(`${this.userboxURL.value}/${targetPath}.chu`).then(b => b.blob()).catch(reject);
if (response)

View File

@ -173,6 +173,7 @@ export async function userboxFileProcess(folder: FileSystemEntry, progressUpdate
const dataFolder = await getDirectoryFromPath(folder, "data");
if (dataFolder)
await scanOptionFolder(dataFolder, progressUpdate);
useLocalStorage("userboxURL", "").value = "";
useLocalStorage("userboxNew", false).value = true;
useLocalStorage("userboxNewProfile", false).value = true;
location.reload();