Make risurealm share and download to use new api
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
if(!latin1.test(enNotes)){
|
||||
alertError("English version of creator notes must contain only Latin-1 characters")
|
||||
}
|
||||
shareRisuHub(char, {
|
||||
shareRisuHub2(char, {
|
||||
anon: privateMode,
|
||||
nsfw: nsfwMode,
|
||||
tag: tags,
|
||||
@@ -79,7 +79,7 @@
|
||||
import { XIcon } from "lucide-svelte";
|
||||
import { language } from "src/lang";
|
||||
import { alertError } from "src/ts/alert";
|
||||
import { shareRisuHub } from "src/ts/characterCards";
|
||||
import { shareRisuHub2 } from "src/ts/characterCards";
|
||||
import { DataBase, type character } from "src/ts/storage/database";
|
||||
import TextInput from "../GUI/TextInput.svelte";
|
||||
import Button from "../GUI/Button.svelte";
|
||||
|
||||
@@ -730,6 +730,7 @@ export async function shareRisuHub2(char:character, arg:{
|
||||
license: string
|
||||
anon: boolean
|
||||
}) {
|
||||
try {
|
||||
char = cloneDeep(char)
|
||||
char.license = arg.license
|
||||
let tagList = arg.tag.split(',')
|
||||
@@ -758,6 +759,7 @@ export async function shareRisuHub2(char:character, arg:{
|
||||
"x-risu-api-version": "4",
|
||||
"x-risu-token": get(DataBase)?.account?.token,
|
||||
'x-risu-username': arg.anon ? '' : (get(DataBase)?.account?.id),
|
||||
'x-risu-debug': 'true'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -769,13 +771,16 @@ export async function shareRisuHub2(char:character, arg:{
|
||||
}
|
||||
else{
|
||||
const resJSON = await res.json()
|
||||
alertNormal(resJSON.message)
|
||||
alertMd(resJSON.message)
|
||||
const currentChar = get(CurrentCharacter)
|
||||
if(currentChar.type === 'group'){
|
||||
return
|
||||
}
|
||||
currentChar.realmId = resJSON.id
|
||||
}
|
||||
} catch (error) {
|
||||
alertError(`${error}`)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -904,12 +909,25 @@ export async function downloadRisuHub(id:string) {
|
||||
type: "wait",
|
||||
msg: "Downloading..."
|
||||
})
|
||||
const res = await fetch(hubURL + '/hub/get/' + id)
|
||||
const res = await fetch(hubURL + '/hub/get/' + id, {
|
||||
headers: {
|
||||
"x-risu-api-version": "4"
|
||||
}
|
||||
})
|
||||
if(res.status !== 200){
|
||||
alertError(await res.text())
|
||||
return
|
||||
}
|
||||
|
||||
if(res.headers.get('content-type') === 'image/png'){
|
||||
await importCharacterProcess({
|
||||
name: 'realm.png',
|
||||
data: res.body
|
||||
})
|
||||
checkCharOrder()
|
||||
return
|
||||
}
|
||||
|
||||
const result = await res.json()
|
||||
const data:CharacterCardV2 = result.card
|
||||
const img:string = result.img
|
||||
|
||||
Reference in New Issue
Block a user