@@ -5,6 +5,7 @@ import { computed, reactive, type Ref, ref } from 'vue';
5
5
6
6
import type { TmdbConfiguration , TmdbImage } from '@dvcol/tmdb-http-client/models' ;
7
7
8
+ import { ErrorService } from '~/services/error.service' ;
8
9
import { TraktService } from '~/services/trakt.service' ;
9
10
import { logger } from '~/stores/settings/log.store' ;
10
11
import { localCache , storage } from '~/utils/browser/browser-storage.utils' ;
@@ -61,7 +62,7 @@ type ImagePayload = {
61
62
profiles ?: TmdbImage [ ] ; // profiles
62
63
} ;
63
64
64
- const EmptyImageStore = {
65
+ const emptyImageStore = {
65
66
movie : { } ,
66
67
show : { } ,
67
68
season : { } ,
@@ -89,9 +90,10 @@ const localArrayMax = (
89
90
90
91
export const useImageStore = defineStore ( ImageStoreConstants . Store , ( ) => {
91
92
const tmdbConfig = ref < TmdbConfiguration > ( ) ;
92
- const images = reactive < ImageStore > ( EmptyImageStore ) ;
93
+ const images = reactive < ImageStore > ( emptyImageStore ) ;
93
94
94
- const imageErrors = reactive < ImageStoreErrors > ( EmptyImageStore ) ;
95
+ const imageErrors = reactive < Partial < ImageStoreErrors > > ( { } ) ;
96
+ ErrorService . registerDictionary ( 'image' , imageErrors ) ;
95
97
96
98
const saveState = debounce (
97
99
( _images = images ) =>
@@ -137,14 +139,15 @@ export const useImageStore = defineStore(ImageStoreConstants.Store, () => {
137
139
const queueRequest = async ( { key, type } : { key : string ; type : ImageQuery [ 'type' ] } , request : ( ) => Promise < ImagePayload > ) => {
138
140
try {
139
141
if ( ! ( key in queue ) ) queue [ key ] = request ( ) ;
140
- delete imageErrors [ type ] [ key ] ;
142
+ const response = await queue [ key ] ;
143
+ delete imageErrors [ type ] ?. [ key ] ;
144
+ return response ;
141
145
} catch ( error ) {
142
146
logger . error ( 'Failed to queue image request' , { key, type } ) ;
143
147
if ( ! imageErrors [ type ] ) imageErrors [ type ] = { } ;
144
- imageErrors [ type ] [ key ] = ErrorCount . fromDictionary ( imageErrors [ type ] , key , error ) ;
148
+ imageErrors [ type ] ! [ key ] = ErrorCount . fromDictionary ( imageErrors [ type ] ! , key , error ) ;
145
149
throw error ;
146
150
}
147
- return queue [ key ] ;
148
151
} ;
149
152
150
153
const getKeyAndType = ( { id, season, episode, type } : ImageQuery ) : { key : string ; type : ImageQuery [ 'type' ] } => {
0 commit comments