Skip to content

Commit

Permalink
preload enums on first edit
Browse files Browse the repository at this point in the history
  • Loading branch information
x87 committed May 20, 2023
1 parent 500ff6b commit b57ae19
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
11 changes: 0 additions & 11 deletions editor/src/app/components/library-page/library-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@ export class LibraryPageComponent implements OnInit, OnDestroy, AfterViewInit {
this.detectScreenSize();
this._ui.toggleCommandListElements(true);

this.canEdit$.pipe(take(1), filter(Boolean)).subscribe(() => {
// we need to preload extensions for cross-edits to work
Object.values(Game).forEach((game) => {
this._extensions.loadExtensions(game);
});

// Object.values(Game).forEach((game) => {
// this._enums.loadEnums(game);
// });
});

getBaseGames().forEach((game) => {
this._snippets.loadSnippets(game);
});
Expand Down
32 changes: 32 additions & 0 deletions editor/src/app/state/ui/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,38 @@ export class UiEffects {
{ dispatch: false }
);

preloadEnums$ = createEffect(
() =>
this._actions$.pipe(
ofType(displayOrEditEnum),
first(({ viewMode }) => viewMode === ViewMode.EditEnum),
tap(() => {
Object.values(Game).forEach((game) => {
this._extensions.loadExtensions(game);
});
Object.values(Game).forEach((game) => {
this._enums.loadEnums(game);
});
})
),
{ dispatch: false }
);

// we need to preload extensions and enums for cross-edits to work
preloadExtensions$ = createEffect(
() =>
this._actions$.pipe(
ofType(displayOrEditCommandInfo),
first(({ viewMode }) => viewMode === ViewMode.EditCommand),
tap(() => {
Object.values(Game).forEach((game) => {
this._extensions.loadExtensions(game);
});
})
),
{ dispatch: false }
);

resetPagination$ = createEffect(() =>
merge(
this._actions$.pipe(
Expand Down

0 comments on commit b57ae19

Please sign in to comment.