Merge branch 'master' into fix-shipping

This commit is contained in:
Kylart 2020-02-02 01:30:02 +01:00
commit 28e933922f
6 changed files with 19 additions and 22 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "KawAnime",
"version": "0.4.1",
"version": "0.4.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "KawAnime",
"version": "0.4.1",
"version": "0.4.2",
"main": "background.js",
"repository": "https://github.com/Kylart/KawAnime.git",
"description": "The ultimate otaku software",

View File

@ -1,5 +1,5 @@
import { setupCreds } from '../../vault'
import { TOKEN_URL, LIST_URL as USER_URL } from '../utils'
import { TOKEN_URL, USERS_URL as USER_URL } from '../utils'
import { https } from '../../../utils'
import { eventsList } from 'vendor'
import sendToWindows from '../../sendToWindows'

View File

@ -147,18 +147,8 @@ export function formatSearch (data) {
}
export function formatList (data) {
const { entries, animes } = data.included.reduce(
(acc, elem) => {
elem.type === 'libraryEntries'
? acc.entries.push(elem)
: acc.animes.push(elem)
return acc
}, {
entries: [],
animes: []
}
)
const entries = data.data
const animes = data.included
return entries.map(({ id, attributes: entry }, index) => {
const anime = animes[index].attributes

View File

@ -2,5 +2,5 @@ export const BASE_URL = 'https://kitsu.io/api/edge/anime'
export const GRAPHQL_ENDPOINT = 'https://kitsu.io/api/graphql'
export const TOKEN_URL = 'https://kitsu.io/api/oauth/token'
export const LIST_URL = 'https://kitsu.io/api/edge/users'
export const UPDATE_LIST_URL = 'https://kitsu.io/api/edge/library-entries'
export const USERS_URL = 'https://kitsu.io/api/edge/users'
export const LIST_URL = 'https://kitsu.io/api/edge/library-entries'

View File

@ -1,14 +1,21 @@
import { https } from '../../utils'
import { LIST_URL, UPDATE_LIST_URL } from './utils'
import { USERS_URL, LIST_URL } from './utils'
import { retrieveToken, isAuthed } from './auth'
import { formatList } from './helpers'
async function get (username) {
try {
const userData = await https.get(USERS_URL, [
{ name: 'filter[slug]', value: username }
])
const { id: userId } = userData.data[0] // Hopefully we won't run into doubles
const data = await https.get(LIST_URL, [
{ name: 'filter[name]', value: username },
{ name: 'include', value: 'libraryEntries,libraryEntries.anime' }
{ name: 'filter[user_id]', value: userId },
{ name: 'include', value: 'anime' },
{ name: 'page[limit]', value: '500' }
], {}, false)
return formatList(data)
@ -31,7 +38,7 @@ async function update (opts) {
}
if (isEdit) {
await https.patch(`${UPDATE_LIST_URL}/${id}`, {
await https.patch(`${LIST_URL}/${id}`, {
data: {
type: 'library-entries',
id,
@ -39,7 +46,7 @@ async function update (opts) {
}
}, [], headers)
} else {
await https.post(UPDATE_LIST_URL, {
await https.post(LIST_URL, {
data: {
type: 'library-entries',
attributes: data,