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 { DataBase } from "src/ts/storage/database";
import { DBState } from "src/ts/storage/database.svelte";
import { getFileSrc } from "src/ts/storage/globalApi";
import { selectedCharID } from "src/ts/stores";
import { selectedCharID } from "src/ts/stores";
import { sleep } from "src/ts/util";
import { onDestroy, onMount } from "svelte";
@@ -41,8 +41,8 @@
})
</script>
{#if $DataBase.characters[$selectedCharID].type === 'character' && $DataBase.characters[$selectedCharID].emotionImages[0]}
{#await getFileSrc($DataBase.characters[$selectedCharID].emotionImages[0][1]) then imglink}
{#if DBState.db.characters[$selectedCharID].type === 'character' && DBState.db.characters[$selectedCharID].emotionImages[0]}
{#await getFileSrc(DBState.db.characters[$selectedCharID].emotionImages[0][1]) then imglink}
<div class="w-full absolute top-0 h-full bottom-0 justify-center flex">
<img src={imglink} alt="character">
</div>
@@ -53,7 +53,7 @@
<div class="w-3xl max-w-full flex flex-col">
<div class="bg-slate-700 h-12 rounded-lg border-slate-500 border-1 w-40 mb-2 bg-opacity-90 text-center flex items-center justify-center">
<span class="font-bold p-2">{$DataBase.characters[$selectedCharID].name}</span>
<span class="font-bold p-2">{DBState.db.characters[$selectedCharID].name}</span>
</div>
<div class="bg-slate-700 h-40 rounded-lg border-slate-500 border-1 w-full bg-opacity-90 text-justify p-4">
Test
@@ -67,7 +67,7 @@
<div class="bg-neutral-200 h-12 rounded-lg border-pink-900 border-1 w-48 mb-2 text-center relative top-6 left-4 text-lg">
<div class="border-pink-300 border-4 h-full rounded-lg">
<div class="border-pink-900 border-1 text-justify h-full rounded-lg flex items-center justify-center">
<span class="font-bold p-2">{$DataBase.characters[$selectedCharID].name}</span>
<span class="font-bold p-2">{DBState.db.characters[$selectedCharID].name}</span>
</div>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { getCustomBackground, getEmotion } from "../../ts/util";
import { DataBase } from "../../ts/storage/database";
import { DBState } from "../../ts/storage/database.svelte";
import BackgroundDom from "../ChatScreens/BackgroundDom.svelte";
import SideBarArrow from "../UI/GUI/SideBarArrow.svelte";
import defaultWallpaper from './test.png'
@@ -12,9 +12,9 @@
let lastBg = $state('')
$effect.pre(() => {
(async () =>{
if($DataBase.customBackground !== lastBg){
lastBg = $DataBase.customBackground
bgImg = await getCustomBackground($DataBase.customBackground)
if(DBState.db.customBackground !== lastBg){
lastBg = DBState.db.customBackground
bgImg = await getCustomBackground(DBState.db.customBackground)
}
})()
});