File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ export const loadScmFileSuccess = createAction(
1616 props < { name : string ; content : ScriptFile } > ( ) ,
1717) ;
1818
19+ export const loadScmFileError = createAction (
20+ '[SCM] Load File Error' ,
21+ props < { name : string } > ( ) ,
22+ ) ;
23+
1924export const loadScmOverlay = createAction (
2025 '[SCM] Load Overlay' ,
2126 props < { game : Game } > ( ) ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212import {
1313 loadMainFile ,
1414 loadScmFile ,
15+ loadScmFileError ,
1516 loadScmFileSuccess ,
1617 loadScmMap ,
1718 loadScmMapError ,
@@ -31,22 +32,32 @@ export class ScmEffects {
3132 loadScmFile$ = createEffect ( ( ) =>
3233 this . _actions$ . pipe (
3334 ofType ( loadScmFile ) ,
34- withLatestFrom ( this . _game . game$ , this . _facade . map$ ) ,
35- switchMap ( ( [ { name } , game , scmMap ] ) => {
36- return this . _facade . fileByName$ ( name ) . pipe (
35+ switchMap ( ( { name } ) =>
36+ this . _game . game$ . pipe (
3737 take ( 1 ) ,
38- switchMap ( ( cachedContent ) => {
39- if ( cachedContent ) {
40- return [ ] ;
41- }
38+ switchMap ( ( game ) =>
39+ this . _facade . mapByGame$ ( game ) . pipe (
40+ take ( 1 ) ,
41+ switchMap ( ( scmMap ) =>
42+ this . _facade . fileByName$ ( name ) . pipe (
43+ take ( 1 ) ,
44+ switchMap ( ( cachedContent ) => {
45+ if ( cachedContent ) {
46+ return [ ] ;
47+ }
4248
43- const base = scmMap . base || `/assets/${ game } /scm` ;
44- return this . _service
45- . loadFile ( name , base )
46- . pipe ( map ( ( content ) => loadScmFileSuccess ( { name, content } ) ) ) ;
47- } ) ,
48- ) ;
49- } ) ,
49+ const base = scmMap ?. base || `/assets/${ game } /scm` ;
50+ return this . _service . loadFile ( name , base ) . pipe (
51+ map ( ( content ) => loadScmFileSuccess ( { name, content } ) ) ,
52+ catchError ( ( ) => of ( loadScmFileError ( { name } ) ) ) ,
53+ ) ;
54+ } ) ,
55+ ) ,
56+ ) ,
57+ ) ,
58+ ) ,
59+ ) ,
60+ ) ,
5061 ) ,
5162 ) ;
5263
You can’t perform that action at this time.
0 commit comments