@@ -19,6 +19,7 @@ import {
19
19
type ListEntity ,
20
20
ListType ,
21
21
} from ' ~/models/list.model' ;
22
+ import { Logger } from ' ~/services/logger.service' ;
22
23
import { NotificationService } from ' ~/services/notification.service' ;
23
24
import { ResolveExternalLinks } from ' ~/settings/external.links' ;
24
25
import { useAppStateStoreRefs } from ' ~/stores/app-state.store' ;
@@ -143,13 +144,17 @@ const onListUpdate = async (value: ListEntity['id'], remove: boolean) => {
143
144
const _list = myLists .value .find (list => list .id === value );
144
145
if (! _list ) return ;
145
146
146
- panelDirty .value = true ;
147
- await addToOrRemoveFromList ({
148
- list: _list ,
149
- itemType: ' movie' ,
150
- itemIds: movie .value ?.ids ,
151
- remove ,
152
- });
147
+ try {
148
+ panelDirty .value = true ;
149
+ await addToOrRemoveFromList ({
150
+ list: _list ,
151
+ itemType: ' movie' ,
152
+ itemIds: movie .value ?.ids ,
153
+ remove ,
154
+ });
155
+ } catch (error ) {
156
+ Logger .error (' Failed to update list' , { list: _list , error });
157
+ }
153
158
};
154
159
155
160
const releaseDate = computed (() => movie .value ?.released );
@@ -163,18 +168,22 @@ const onCollectionUpdate = async (
163
168
date = releaseDate .value ;
164
169
}
165
170
166
- panelDirty .value = true ;
167
- await addToOrRemoveFromList ({
168
- list: DefaultLists .ShowCollection ,
169
- itemType: ' movie' ,
170
- itemIds: movie .value ?.ids ,
171
- date ,
172
- remove: value === PanelButtonsOption .Remove ,
173
- });
174
-
175
- const _id = movie .value ?.ids ?.trakt ;
176
- if (_id === undefined ) return ;
177
- return changeMovieCollected (_id , value === PanelButtonsOption .Remove );
171
+ try {
172
+ panelDirty .value = true ;
173
+ await addToOrRemoveFromList ({
174
+ list: DefaultLists .ShowCollection ,
175
+ itemType: ' movie' ,
176
+ itemIds: movie .value ?.ids ,
177
+ date ,
178
+ remove: value === PanelButtonsOption .Remove ,
179
+ });
180
+
181
+ const _id = movie .value ?.ids ?.trakt ;
182
+ if (_id === undefined ) return ;
183
+ return await changeMovieCollected (_id , value === PanelButtonsOption .Remove );
184
+ } catch (error ) {
185
+ Logger .error (' Failed to update collection' , error );
186
+ }
178
187
};
179
188
180
189
const onWatchedUpdate = async (
@@ -186,22 +195,26 @@ const onWatchedUpdate = async (
186
195
date = releaseDate .value ;
187
196
}
188
197
189
- panelDirty .value = true ;
190
- await addToOrRemoveFromList ({
191
- list: {
192
- id: DefaultListId .History ,
193
- type: ListType .History ,
194
- name: ' list_type__history' ,
195
- },
196
- itemType: ' movie' ,
197
- itemIds: movie .value ?.ids ,
198
- date ,
199
- remove: value === PanelButtonsOption .Remove ,
200
- });
201
-
202
- const _id = movie .value ?.ids ?.trakt ;
203
- if (_id === undefined ) return ;
204
- return changeMovieWatched (_id , value === PanelButtonsOption .Remove );
198
+ try {
199
+ panelDirty .value = true ;
200
+ await addToOrRemoveFromList ({
201
+ list: {
202
+ id: DefaultListId .History ,
203
+ type: ListType .History ,
204
+ name: ' list_type__history' ,
205
+ },
206
+ itemType: ' movie' ,
207
+ itemIds: movie .value ?.ids ,
208
+ date ,
209
+ remove: value === PanelButtonsOption .Remove ,
210
+ });
211
+
212
+ const _id = movie .value ?.ids ?.trakt ;
213
+ if (_id === undefined ) return ;
214
+ return await changeMovieWatched (_id , value === PanelButtonsOption .Remove );
215
+ } catch (error ) {
216
+ Logger .error (' Failed to update watched status' , error );
217
+ }
205
218
};
206
219
207
220
const i18n = useI18n (' movie' , ' panel' );
@@ -233,20 +246,24 @@ const { cancel: cancelCheckin, checkin } = useWatchingStore();
233
246
234
247
const { onCancel } = useCancelWatching (cancelCheckin );
235
248
const onCheckin = async (cancel : boolean ) => {
236
- if (cancel ) {
237
- const cancelled = await onCancel ();
238
- if (! cancelled ) return ;
239
- } else if (! movie .value ?.ids ?.trakt ) {
240
- return NotificationService .error (
241
- i18n (' checkin_failed' , ' watching' ),
242
- new Error (' No movie id' ),
243
- );
244
- } else {
245
- panelDirty .value = true ;
246
- await checkin ({ movie: { ids: movie .value .ids } });
247
- }
249
+ try {
250
+ if (cancel ) {
251
+ const cancelled = await onCancel ();
252
+ if (! cancelled ) return ;
253
+ } else if (! movie .value ?.ids ?.trakt ) {
254
+ return NotificationService .error (
255
+ i18n (' checkin_failed' , ' watching' ),
256
+ new Error (' No movie id' ),
257
+ );
258
+ } else {
259
+ panelDirty .value = true ;
260
+ await checkin ({ movie: { ids: movie .value .ids } });
261
+ }
248
262
249
- await fetchMovieWatched (true );
263
+ await fetchMovieWatched (true );
264
+ } catch (error ) {
265
+ Logger .error (' Failed to checkin' , error );
266
+ }
250
267
};
251
268
252
269
onMounted (() => {
0 commit comments