Change DataBase inside svelte to DBState for performance

This commit is contained in:
kwaroran
2024-10-23 23:46:32 +09:00
parent a9f1819044
commit 2044d9b63b
122 changed files with 1372 additions and 1424 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { alertMd } from "src/ts/alert";
import { shareRealmCardData } from "src/ts/realm";
import { DataBase, downloadPreset } from "src/ts/storage/database";
import { DBState, downloadPreset } from "src/ts/storage/database.svelte";
import { selectedCharID, ShowRealmFrameStore } from "src/ts/stores";
import { sleep } from "src/ts/util";
import { onDestroy, onMount } from "svelte";
@@ -10,8 +10,8 @@
$ShowRealmFrameStore = ''
}
let iframe: HTMLIFrameElement = $state(null)
const tk = $DataBase?.account?.token;
const id = $DataBase?.account?.id
const tk = DBState.db?.account?.token;
const id = DBState.db?.account?.id
let loadingStage = $state(0)
let pongGot = false
@@ -30,9 +30,9 @@
if($ShowRealmFrameStore.startsWith('preset') || $ShowRealmFrameStore.startsWith('module')){
//TODO, add preset edit
}
else if($DataBase.characters[$selectedCharID].type === 'character'){
else if(DBState.db.characters[$selectedCharID].type === 'character'){
loadingStage = 0
$DataBase.characters[$selectedCharID].realmId = e.data.id
DBState.db.characters[$selectedCharID].realmId = e.data.id
}
close()
}
@@ -67,7 +67,7 @@
}
}
else if($ShowRealmFrameStore.startsWith('module')){
const predata = $DataBase.modules[Number($ShowRealmFrameStore.split(':')[1])]
const predata = DBState.db.modules[Number($ShowRealmFrameStore.split(':')[1])]
//@ts-ignore
predata.type = 'risuModule'
const encodedPredata = new TextEncoder().encode(JSON.stringify(predata))
@@ -96,8 +96,8 @@
if($ShowRealmFrameStore.startsWith('preset') || $ShowRealmFrameStore.startsWith('module')){
//TODO, add preset edit
}
else if($DataBase.characters[$selectedCharID].type === 'character' && $DataBase.characters[$selectedCharID].realmId){
url += `&edit=${$DataBase.characters[$selectedCharID].realmId}&edit-type=normal`
else if(DBState.db.characters[$selectedCharID].type === 'character' && DBState.db.characters[$selectedCharID].realmId){
url += `&edit=${DBState.db.characters[$selectedCharID].realmId}&edit-type=normal`
}
url += '#noLayout'
return url

View File

@@ -3,7 +3,7 @@
import { language } from "src/lang";
import { alertConfirm, alertInput, alertNormal } from "src/ts/alert";
import { hubURL, type hubType, downloadRisuHub, getRealmInfo } from "src/ts/characterCards";
import { DataBase } from "src/ts/storage/database";
import { DBState } from "src/ts/storage/database.svelte";
import RealmLicense from "./RealmLicense.svelte";
import MultiLangDisplay from "../GUI/MultiLangDisplay.svelte";
import { tooltip } from "src/ts/gui/tooltip";
@@ -86,7 +86,7 @@
})}>
<FlagIcon />
</button>
{#if ($DataBase.account?.token?.split('-') ?? [])[1] === openedData.creator}
{#if (DBState.db.account?.token?.split('-') ?? [])[1] === openedData.creator}
<button class="text-textcolor2 hover:text-red-500" onclick={(async (e) => {
e.stopPropagation()
const conf = await alertConfirm('Do you want to remove this character from Realm?')
@@ -95,7 +95,7 @@
method: "POST",
body: JSON.stringify({
id: openedData.id,
token: $DataBase.account?.token
token: DBState.db.account?.token
})
})
alertNormal(await da.text())

View File

@@ -5,7 +5,7 @@
onclick?.(e)
}}>
{#if !$DataBase.account}
{#if !DBState.db.account}
<span class="font-bold text-2xl w-full">You must login to Risu Account upload to RisuRealm</span>
<span class="text-textcolor2">You can login in app settings 🡲 account</span>
<button onclick={async () => {
@@ -111,7 +111,7 @@
import { language } from "src/lang";
import { alertError } from "src/ts/alert";
import { shareRisuHub2 } from "src/ts/characterCards";
import { DataBase, type character } from "src/ts/storage/database";
import { DBState, type character } from "src/ts/storage/database.svelte";
import TextInput from "../GUI/TextInput.svelte";
import Button from "../GUI/Button.svelte";
import SelectInput from "../GUI/SelectInput.svelte";