@@ -265,36 +265,44 @@ class SyncNotifier extends StateNotifier<SyncSettingsModel> {
265265 }
266266
267267 Future <void > addSyncItem (BuildContext ? context, ItemBaseModel item) async {
268- if (context == null ) return ;
269-
270- if (saveDirectory == null ) {
271- String ? selectedDirectory =
272- await FilePicker .platform.getDirectoryPath (dialogTitle: context.localized.syncSelectDownloadsFolder);
273- if (selectedDirectory? .isEmpty == true && context.mounted) {
274- fladderSnackbar (context, title: context.localized.syncNoFolderSetup);
275- return ;
268+ try {
269+ if (context == null ) return ;
270+
271+ if (saveDirectory == null ) {
272+ String ? selectedDirectory =
273+ await FilePicker .platform.getDirectoryPath (dialogTitle: context.localized.syncSelectDownloadsFolder);
274+ if (selectedDirectory? .isEmpty == true && context.mounted) {
275+ fladderSnackbar (context, title: context.localized.syncNoFolderSetup);
276+ return ;
277+ }
278+ ref.read (clientSettingsProvider.notifier).setSyncPath (selectedDirectory);
276279 }
277- ref.read (clientSettingsProvider.notifier).setSyncPath (selectedDirectory);
278- }
279280
280- if (context.mounted) {
281- fladderSnackbar (context, title: context.localized.syncAddItemForSyncing (item.detailedName (context) ?? "Unknown" ));
282- }
283- final newSync = switch (item) {
284- EpisodeModel episode => await syncSeries (item.parentBaseModel, episode: episode),
285- SeasonModel season => await syncSeries (item.parentBaseModel, season: season),
286- SeriesModel series => await syncSeries (series),
287- MovieModel movie => await syncMovie (movie),
288- _ => null
289- };
290- if (context.mounted) {
291- fladderSnackbar (context,
292- title: newSync != null
293- ? context.localized.startedSyncingItem (item.detailedName (context) ?? "Unknown" )
294- : context.localized.unableToSyncItem (item.detailedName (context) ?? "Unknown" ));
295- }
281+ if (context.mounted) {
282+ fladderSnackbar (context,
283+ title: context.localized.syncAddItemForSyncing (item.detailedName (context) ?? "Unknown" ));
284+ }
285+ final newSync = switch (item) {
286+ EpisodeModel episode => await syncSeries (item.parentBaseModel, episode: episode),
287+ SeasonModel season => await syncSeries (item.parentBaseModel, season: season),
288+ SeriesModel series => await syncSeries (series),
289+ MovieModel movie => await syncMovie (movie),
290+ _ => null
291+ };
292+ if (context.mounted) {
293+ fladderSnackbar (context,
294+ title: newSync != null
295+ ? context.localized.startedSyncingItem (item.detailedName (context) ?? "Unknown" )
296+ : context.localized.unableToSyncItem (item.detailedName (context) ?? "Unknown" ));
297+ }
296298
297- return ;
299+ return ;
300+ } catch (e) {
301+ log ('Error adding sync item: ${e .toString ()}' );
302+ if (context? .mounted == true ) {
303+ fladderSnackbar (context! , title: context.localized.somethingWentWrong);
304+ }
305+ }
298306 }
299307
300308 void viewDatabase (BuildContext context) =>
0 commit comments