Fix rendering issues with dialog by using zone to process main process requests
Some checks failed
E2E Testing / test (push) Failing after 1m37s

This commit is contained in:
Sebastian Böckelmann 2024-03-20 17:00:44 +01:00
parent 2a02ec9338
commit 09abfcaa89
2 changed files with 33 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import {Component, OnInit, ViewChild} from '@angular/core'; import {Component, NgZone, OnInit, ViewChild} from '@angular/core';
import {MatDrawerContainer} from "@angular/material/sidenav"; import {MatDrawerContainer} from "@angular/material/sidenav";
import {EditorComponent} from "./editor/editor.component"; import {EditorComponent} from "./editor/editor.component";
import { import {
@ -36,9 +36,30 @@ export class AppComponent implements OnInit{
gameModel: GameModel | undefined gameModel: GameModel | undefined
constructor(private electronService: ElectronService, constructor(private electronService: ElectronService,
private dialog: MatDialog private dialog: MatDialog,
private zone: NgZone
) { ) {
if(electronService.isElectron) {
electronService.ipcRenderer.on('context-menu', (event: any, message: string) => {
this.zone.run(() => {
this.onContextMenuMessageRecieved(message);
});
})
electronService.ipcRenderer.on('get-project-data', (event: any, message: string) => {
this.zone.run(() => {
this.onSaveProject();
})
})
electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => {
this.zone.run(() => {
this.onLoadProject(loadedProject)
})
})
}
} }
onContextMenuMessageRecieved(message: string) { onContextMenuMessageRecieved(message: string) {
@ -142,21 +163,7 @@ export class AppComponent implements OnInit{
} }
ngOnInit() { ngOnInit() {
if(this.electronService.isElectron) {
this.electronService.ipcRenderer.on('get-project-data', () => {
this.onSaveProject();
})
this.electronService.ipcRenderer.on('open-project', (event: any, loadedProject: StoredGameModel) => {
this.onLoadProject(loadedProject);
})
this.electronService.ipcRenderer.on('context-menu', (event: any, message: string) => {
console.log("Context Menu triggered")
this.onContextMenuMessageRecieved(message);
})
}
} }
onLoadProject(storedGameModel: StoredGameModel) { onLoadProject(storedGameModel: StoredGameModel) {

View File

@ -1,6 +1,7 @@
import {Component, Inject} from '@angular/core'; import {Component, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {ModelComponent} from "../project/game-model/ModelComponent"; import {ModelComponent} from "../project/game-model/ModelComponent";
import {ModelComponentTypeUtillities} from "../project/game-model/ModelComponentTypeUtillities";
@Component({ @Component({
@ -8,12 +9,17 @@ import {ModelComponent} from "../project/game-model/ModelComponent";
templateUrl: './delete-confirmation-dialog.component.html', templateUrl: './delete-confirmation-dialog.component.html',
styleUrl: './delete-confirmation-dialog.component.scss' styleUrl: './delete-confirmation-dialog.component.scss'
}) })
export class DeleteConfirmationDialogComponent { export class DeleteConfirmationDialogComponent implements OnInit{
constructor(private dialogRef: MatDialogRef<DeleteConfirmationDialogComponent>, constructor(private dialogRef: MatDialogRef<DeleteConfirmationDialogComponent>,
@Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) { @Inject(MAT_DIALOG_DATA) public deleteModelComponent: ModelComponent) {
} }
ngOnInit(): void {
console.log("delete Confirmation dialog here")
}
cancel() { cancel() {
this.dialogRef.close(false); this.dialogRef.close(false);
} }
@ -21,4 +27,6 @@ export class DeleteConfirmationDialogComponent {
confirmDelete() { confirmDelete() {
this.dialogRef.close(true); this.dialogRef.close(true);
} }
protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
} }