Skip to content

Commit b57ae19

Browse files
committed
preload enums on first edit
1 parent 500ff6b commit b57ae19

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

editor/src/app/components/library-page/library-page.component.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,6 @@ export class LibraryPageComponent implements OnInit, OnDestroy, AfterViewInit {
135135
this.detectScreenSize();
136136
this._ui.toggleCommandListElements(true);
137137

138-
this.canEdit$.pipe(take(1), filter(Boolean)).subscribe(() => {
139-
// we need to preload extensions for cross-edits to work
140-
Object.values(Game).forEach((game) => {
141-
this._extensions.loadExtensions(game);
142-
});
143-
144-
// Object.values(Game).forEach((game) => {
145-
// this._enums.loadEnums(game);
146-
// });
147-
});
148-
149138
getBaseGames().forEach((game) => {
150139
this._snippets.loadSnippets(game);
151140
});

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,38 @@ export class UiEffects {
273273
{ dispatch: false }
274274
);
275275

276+
preloadEnums$ = createEffect(
277+
() =>
278+
this._actions$.pipe(
279+
ofType(displayOrEditEnum),
280+
first(({ viewMode }) => viewMode === ViewMode.EditEnum),
281+
tap(() => {
282+
Object.values(Game).forEach((game) => {
283+
this._extensions.loadExtensions(game);
284+
});
285+
Object.values(Game).forEach((game) => {
286+
this._enums.loadEnums(game);
287+
});
288+
})
289+
),
290+
{ dispatch: false }
291+
);
292+
293+
// we need to preload extensions and enums for cross-edits to work
294+
preloadExtensions$ = createEffect(
295+
() =>
296+
this._actions$.pipe(
297+
ofType(displayOrEditCommandInfo),
298+
first(({ viewMode }) => viewMode === ViewMode.EditCommand),
299+
tap(() => {
300+
Object.values(Game).forEach((game) => {
301+
this._extensions.loadExtensions(game);
302+
});
303+
})
304+
),
305+
{ dispatch: false }
306+
);
307+
276308
resetPagination$ = createEffect(() =>
277309
merge(
278310
this._actions$.pipe(

0 commit comments

Comments
 (0)