From 6060dea8c448023c27c66eaa653e8037ef9784ad Mon Sep 17 00:00:00 2001 From: robinknaapen Date: Thu, 13 Dec 2018 21:38:02 +0100 Subject: [PATCH] Extend interfaces and fix store userAnime store name --- src/store/module/userAnime.ts | 14 +++++++------- src/types/shims-vue.d.ts | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/store/module/userAnime.ts b/src/store/module/userAnime.ts index 5c97698..6e15cfb 100644 --- a/src/store/module/userAnime.ts +++ b/src/store/module/userAnime.ts @@ -3,36 +3,36 @@ import { RootState } from '@/store' import { BareActionContext, getStoreBuilder } from 'vuex-typex' export interface UserAnimeState { - anime: Meikan.UserAnime[] + userAnime: Meikan.UserAnime[] } const initialState: UserAnimeState = { - anime: [], + userAnime: [], } const builder = getStoreBuilder().module('userAnime', initialState) // Getters const getterUserAnime = builder.read(function anime(state: UserAnimeState) { - return state.anime + return state.userAnime }) // Mutations function setAnime(state: UserAnimeState, animeList: Meikan.UserAnime[]) { - state.anime = animeList + state.userAnime = animeList } // Action async function fetchUserAnime(context: BareActionContext, user: Meikan.User) { const list = await GetUserAnime(user.id) - userAnime.setAnime(list) + userAnimeState.setAnime(list) } function resetUserAnime(context: BareActionContext) { - userAnime.setAnime([]) + userAnimeState.setAnime([]) } -export const userAnime = { +export const userAnimeState = { get anime(): Meikan.UserAnime[] { return getterUserAnime() }, diff --git a/src/types/shims-vue.d.ts b/src/types/shims-vue.d.ts index 0f2f124..8efc84a 100644 --- a/src/types/shims-vue.d.ts +++ b/src/types/shims-vue.d.ts @@ -9,8 +9,27 @@ declare namespace Meikan { name: string } - export interface UserAnime { + export interface Anime { id: number title: string + type: string + episodes: number + state: string + rating: string + start_date: string + end_date: string + genres: string[] + average_duration: number + anidb_id: number + myanimelist_id: number + } + + export interface UserAnime { + anime: Anime + state: string + episode: number + rating?: number + hidden: boolean + recommend: boolean } }