@@ -33,40 +33,56 @@ export class ExportContainer extends PureComponent {
33
33
34
34
const { boards, intl, activeBoardId, showNotification } = this . props ;
35
35
// TODO: Make this block easier to follow.
36
- if ( type === 'openboard' && singleBoard ) {
37
- await EXPORT_HELPERS . openboardExportAdapter ( singleBoard , intl ) ;
38
- } else if ( type === 'cboard' ) {
39
- await EXPORT_HELPERS . cboardExportAdapter ( boards , singleBoard ) ;
40
- } else if ( type === 'picsee_pdf' ) {
41
- if ( singleBoard ) {
42
- await EXPORT_HELPERS [ exportConfig . callback ] ( [ singleBoard ] , intl , true ) ;
36
+ try {
37
+ if ( type === 'openboard' && singleBoard ) {
38
+ await EXPORT_HELPERS . openboardExportAdapter ( singleBoard , intl ) ;
39
+ } else if ( type === 'cboard' ) {
40
+ await EXPORT_HELPERS . cboardExportAdapter ( boards , singleBoard ) ;
41
+ } else if ( type === 'picsee_pdf' ) {
42
+ if ( singleBoard ) {
43
+ await EXPORT_HELPERS [ exportConfig . callback ] (
44
+ [ singleBoard ] ,
45
+ intl ,
46
+ true
47
+ ) ;
48
+ } else {
49
+ const currentBoard = boards . filter (
50
+ board => board . id === activeBoardId
51
+ ) ;
52
+ await EXPORT_HELPERS [ exportConfig . callback ] ( currentBoard , intl , true ) ;
53
+ }
54
+ } else if ( type !== 'pdf' && ! singleBoard ) {
55
+ await EXPORT_HELPERS [ exportConfig . callback ] ( boards , intl ) ;
43
56
} else {
44
- const currentBoard = boards . filter ( board => board . id === activeBoardId ) ;
45
- await EXPORT_HELPERS [ exportConfig . callback ] ( currentBoard , intl , true ) ;
57
+ if ( singleBoard ) {
58
+ await EXPORT_HELPERS [ exportConfig . callback ] ( [ singleBoard ] , intl ) ;
59
+ } else {
60
+ const currentBoard = boards . filter (
61
+ board => board . id === activeBoardId
62
+ ) ;
63
+ await EXPORT_HELPERS [ exportConfig . callback ] ( currentBoard , intl ) ;
64
+ }
46
65
}
47
- } else if ( type !== 'pdf' && ! singleBoard ) {
48
- await EXPORT_HELPERS [ exportConfig . callback ] ( boards , intl ) ;
49
- } else {
50
- if ( singleBoard ) {
51
- await EXPORT_HELPERS [ exportConfig . callback ] ( [ singleBoard ] , intl ) ;
52
- } else {
53
- const currentBoard = boards . filter ( board => board . id === activeBoardId ) ;
54
- await EXPORT_HELPERS [ exportConfig . callback ] ( currentBoard , intl ) ;
55
- }
56
- }
57
- const showBoardDowloadedNotification = ( ) => {
58
- if ( isAndroid ( ) )
59
- return showNotification (
60
- intl . formatMessage ( messages . boardDownloadedCva )
61
- ) ;
62
- if ( isIOS ( ) )
63
- return showNotification (
64
- intl . formatMessage ( messages . boardDownloadedCvaIOS )
65
- ) ;
66
- return showNotification ( intl . formatMessage ( messages . boardDownloaded ) ) ;
67
- } ;
66
+ const showBoardDowloadedNotification = ( ) => {
67
+ if ( isAndroid ( ) )
68
+ return showNotification (
69
+ intl . formatMessage ( messages . boardDownloadedCva )
70
+ ) ;
71
+ if ( isIOS ( ) )
72
+ return showNotification (
73
+ intl . formatMessage ( messages . boardDownloadedCvaIOS )
74
+ ) ;
75
+ return showNotification ( intl . formatMessage ( messages . boardDownloaded ) ) ;
76
+ } ;
68
77
69
- showBoardDowloadedNotification ( ) ;
78
+ showBoardDowloadedNotification ( ) ;
79
+ } catch ( e ) {
80
+ console . error ( e ) ;
81
+ const message = e . reason ?. message ?. startsWith ( 'Failed to fetch' )
82
+ ? messages . downloadNoConnectionError
83
+ : messages . boardDownloadError ;
84
+ showNotification ( intl . formatMessage ( message ) ) ;
85
+ }
70
86
doneCallback ( ) ;
71
87
} ;
72
88
0 commit comments