chore: syntax fun

This commit is contained in:
ThaUnknown 2022-06-13 00:02:14 +02:00
parent b02d0645f5
commit 0e38e0d727
4 changed files with 23 additions and 24 deletions

View file

@ -229,7 +229,7 @@
const entries = await getRSSEntries({ media, episode })
if (!entries?.length) {
addToast({
text: `Couldn't find torrent for ${media.title.userPreferred} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
text: /* html */`Couldn't find torrent for ${media.title.userPreferred} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
title: 'Search Failed',
type: 'danger'
})

View file

@ -8,7 +8,7 @@
let code = ''
let timeout = null
function rej() {
function rej () {
addToast({
text: 'Could not establish connection, please try again.',
title: 'Connection Timed Out',
@ -37,7 +37,7 @@
$: value = (step?.mode === 'copy' && code) || null
function handleInput({ target }) {
function handleInput ({ target }) {
let val = null
try {
val = JSON.parse(atob(target.value))
@ -72,15 +72,14 @@
index = index + 1
}
function copyData() {
function copyData () {
navigator.clipboard.writeText(value)
index = index + 1
}
let index = 0
$: step = map[state]?.[index]
let map = {
const map = {
guest: [
{
title: 'Paste Invite Code',
@ -106,6 +105,8 @@
}
]
}
$: step = map[state]?.[index]
</script>
<div class="h-full d-flex flex-column justify-content-center mb-20 pb-20 root container">

View file

@ -65,7 +65,7 @@ export const alID = !!alToken && alRequest({ method: 'Viewer', token: alToken })
function printError (error) {
console.warn(error)
addToast({
text: `Failed making request to anilist!<br>Try again in a minute.<br>${error.status} - ${error.message || codes[error.status]}`,
text: /* html */`Failed making request to anilist!<br>Try again in a minute.<br>${error.status} - ${error.message || codes[error.status]}`,
title: 'Search Failed',
type: 'danger',
duration: 3000
@ -138,7 +138,7 @@ export async function alRequest (opts) {
Accept: 'application/json'
}
}
const queryObjects = `
const queryObjects = /* js */`
id,
title {
romaji,
@ -146,9 +146,7 @@ title {
native,
userPreferred
},
description(
asHtml: true
),
description(asHtml: true),
season,
seasonYear,
format,
@ -229,7 +227,7 @@ relations {
switch (opts.method) {
case 'SearchName': {
variables.search = opts.name
query = `
query = /* js */`
query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType, $search: String, $status: [MediaStatus]) {
Page (page: $page, perPage: $perPage) {
pageInfo {
@ -243,7 +241,7 @@ query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType, $search:
break
} case 'SearchIDSingle': {
variables.id = opts.id
query = `
query = /* js */`
query ($id: Int, $type: MediaType) {
Media (id: $id, type: $type) {
${queryObjects}
@ -252,7 +250,7 @@ query ($id: Int, $type: MediaType) {
break
} case 'SearchIDS': {
variables.id = opts.id
query = `
query = /* js */`
query ($id: [Int], $type: MediaType, $page: Int, $perPage: Int) {
Page (page: $page, perPage: $perPage) {
pageInfo {
@ -266,7 +264,7 @@ query ($id: [Int], $type: MediaType, $page: Int, $perPage: Int) {
break
} case 'Viewer': {
variables.id = alToken
query = `
query = /* js */`
query {
Viewer {
avatar {
@ -279,7 +277,7 @@ query {
break
} case 'UserLists': {
variables.id = (await alID)?.data?.Viewer?.id
query = `
query = /* js */`
query ($page: Int, $perPage: Int, $id: Int, $type: MediaType, $status_in: [MediaListStatus]){
Page (page: $page, perPage: $perPage) {
pageInfo {
@ -296,7 +294,7 @@ query ($page: Int, $perPage: Int, $id: Int, $type: MediaType, $status_in: [Media
} case 'SearchIDStatus': {
variables.id = (await alID)?.data?.Viewer?.id
variables.mediaId = opts.id
query = `
query = /* js */`
query ($id: Int, $mediaId: Int){
MediaList(userId: $id, mediaId: $mediaId) {
status,
@ -308,7 +306,7 @@ query ($id: Int, $mediaId: Int){
} case 'AiringSchedule': {
variables.from = opts.from
variables.to = (variables.from + 7 * 24 * 60 * 60)
query = `
query = /* js */`
query ($page: Int, $perPage: Int, $from: Int, $to: Int) {
Page (page: $page, perPage: $perPage) {
pageInfo {
@ -332,7 +330,7 @@ query ($page: Int, $perPage: Int, $from: Int, $to: Int) {
variables.season = opts.season
variables.format = opts.format
variables.sort = opts.sort || 'SEARCH_MATCH'
query = `
query = /* js */`
query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType, $search: String, $status: MediaStatus, $season: MediaSeason, $year: Int, $genre: String, $format: MediaFormat) {
Page (page: $page, perPage: $perPage) {
pageInfo {
@ -350,7 +348,7 @@ query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType, $search:
variables.status = opts.status
variables.episode = opts.episode
variables.score = opts.score
query = `
query = /* js */`
mutation ($id: Int, $status: MediaListStatus, $episode: Int, $repeat: Int, $score: Int) {
SaveMediaListEntry (mediaId: $id, status: $status, progress: $episode, repeat: $repeat, scoreRaw: $score) {
id,
@ -362,7 +360,7 @@ query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType, $search:
break
} case 'Delete': {
variables.id = opts.id
query = `
query = /* js */`
mutation ($id: Int) {
DeleteMediaListEntry (id: $id){
deleted

View file

@ -49,14 +49,14 @@ function traceAnime (image, type) { // WAIT lookup logic
reader.onload = e => {
addToast({
title: 'Looking up anime for image',
text: `<img class="w-200 rounded pt-5" src="${e.target.result}">`
text: /* html */`<img class="w-200 rounded pt-5" src="${e.target.result}">`
})
}
reader.readAsDataURL(image.get('image'))
} else {
addToast({
title: 'Looking up anime for image',
text: `<img class="w-200 rounded pt-5" src="${image}">`
text: /* html */`<img class="w-200 rounded pt-5" src="${image}">`
})
}
let options
@ -272,7 +272,7 @@ export async function resolveSeason (opts) {
if (!force) {
console.warn('Error in parsing!', obj)
addToast({
text: `Failed resolving anime episode!<br>${media.title.userPreferred} - ${episode - offset}`,
text: /* html */`Failed resolving anime episode!<br>${media.title.userPreferred} - ${episode - offset}`,
title: 'Parsing Error',
type: 'secondary'
})