Migrate all DataBase to DBState

This commit is contained in:
kwaroran
2024-10-24 01:59:57 +09:00
parent 4e9190f1b5
commit b3fddb814e
65 changed files with 331 additions and 434 deletions

View File

@@ -1,7 +1,6 @@
import { get } from "svelte/store";
import { DataBase } from "../storage/database.svelte";
import { getDatabase } from "../storage/database.svelte";
export function updateAnimationSpeed(){
const db = get(DataBase);
const db = getDatabase();
document.documentElement.style.setProperty('--risu-animation-speed', db.animationSpeed + 's');
}

View File

@@ -1,5 +1,5 @@
import { get, writable } from "svelte/store";
import { DataBase, setDatabase } from "../storage/database.svelte";
import { getDatabase, setDatabase } from "../storage/database.svelte";
import { downloadFile } from "../storage/globalApi";
import { BufferToText, selectSingleFile } from "../util";
import { alertError } from "../alert";
@@ -115,7 +115,7 @@ export const ColorSchemeTypeStore = writable('dark' as 'dark'|'light')
export const colorSchemeList = Object.keys(colorShemes) as (keyof typeof colorShemes)[]
export function changeColorScheme(colorScheme: string){
let db = get(DataBase)
let db = getDatabase()
if(colorScheme !== 'custom'){
db.colorScheme = structuredClone(colorShemes[colorScheme])
}
@@ -125,7 +125,7 @@ export function changeColorScheme(colorScheme: string){
}
export function updateColorScheme(){
let db = get(DataBase)
let db = getDatabase()
let colorScheme = db.colorScheme
@@ -151,7 +151,7 @@ export function updateColorScheme(){
}
export function exportColorScheme(){
let db = get(DataBase)
let db = getDatabase()
let json = JSON.stringify(db.colorScheme)
downloadFile('colorScheme.json', json)
}
@@ -181,7 +181,7 @@ export async function importColorScheme(){
return
}
changeColorScheme('custom')
let db = get(DataBase)
let db = getDatabase()
db.colorScheme = colorScheme
setDatabase(db)
updateColorScheme()
@@ -194,7 +194,7 @@ export async function importColorScheme(){
}
export function updateTextThemeAndCSS(){
let db = get(DataBase)
let db = getDatabase()
const root = document.querySelector(':root') as HTMLElement;
if(!root){
return

View File

@@ -1,12 +1,12 @@
import { get, writable } from "svelte/store";
import { DataBase } from "../storage/database.svelte";
import { writable } from "svelte/store";
import { getDatabase } from "../storage/database.svelte";
export let textAreaSize = writable(0)
export let sideBarSize = writable(0)
export let textAreaTextSize = writable(0)
export function updateGuisize(){
let db = get(DataBase)
let db = getDatabase()
const root = document.querySelector(':root') as HTMLElement;
if(!root){
return