Skip to content

Commit 18f33d7

Browse files
committed
fix scm deeplink
1 parent 0d4018e commit 18f33d7

2 files changed

Lines changed: 30 additions & 14 deletions

File tree

editor/src/app/state/scm/actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
1924
export const loadScmOverlay = createAction(
2025
'[SCM] Load Overlay',
2126
props<{ game: Game }>(),

editor/src/app/state/scm/effects.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import {
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

0 commit comments

Comments
 (0)