chore: Add loadAutoServerBackup button to UserSettings page

This commit is contained in:
kwaroran
2024-06-09 19:02:53 +09:00
parent 5f6466b70c
commit 8edad562e8
3 changed files with 44 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
import { get } from "svelte/store"
import { hubURL } from "../characterCards"
import { DataBase } from "../storage/database"
import { alertError } from "../alert"
import { alertError, alertSelect } from "../alert"
export async function risuLogin() {
const win = window.open(hubURL + '/hub/login')
@@ -49,4 +49,34 @@ export async function loadRisuAccountData() {
return
}
db.account.data = await s.json()
}
export async function loadRisuAccountBackup() {
const db = get(DataBase)
if(!db.account){
alertError("Not logged in error")
return
}
const s = await fetch(hubURL + '/hub/backup/list', {
method: "GET",
headers: {
"x-risu-auth": db.account.token
}
})
if(s.status !== 200){
alertError(await s.text())
return
}
const backups = await s.json()
if(!backups.length){
alertError("No backups found")
return
}
const backupIdStr = await alertSelect(backups)
const backupIdNum = parseInt(backupIdStr)
if(isNaN(backupIdNum)){
alertError("Invalid backup id")
return
}
const backupId = backups[backupIdNum]
}