From f1b38832de9d8c6c7d3bbc091aa2eb5f97c45788 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Mon, 20 Sep 2021 14:43:34 +0200
Subject: [PATCH] [editor] Minor Refactoring

Remove useless methods and add comments.
---
 .../unit-view/unit-view.component.ts          | 20 +++++++++----------
 projects/editor/src/app/unit.service.ts       |  1 +
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/projects/editor/src/app/components/unit-view/unit-view.component.ts b/projects/editor/src/app/components/unit-view/unit-view.component.ts
index 683e21434..d9087fd59 100644
--- a/projects/editor/src/app/components/unit-view/unit-view.component.ts
+++ b/projects/editor/src/app/components/unit-view/unit-view.component.ts
@@ -1,5 +1,5 @@
 import { Component, OnDestroy, OnInit } from '@angular/core';
-import { Observable, Subject } from 'rxjs';
+import { Subject } from 'rxjs';
 import { takeUntil } from 'rxjs/operators';
 import { UnitService } from '../../unit.service';
 import { DialogService } from '../../dialog.service';
@@ -68,12 +68,14 @@ export class UnitViewComponent implements OnInit, OnDestroy {
   }
 
   deletePage(page: UnitPage): void {
-    this.showConfirmDialog().pipe(takeUntil(this.ngUnsubscribe)).subscribe((result: boolean) => {
-      if (result) {
-        this.unitService.deletePage(page);
-        this.selectedPageIndex -= 1;
-      }
-    });
+    this.dialogService.showConfirmDialog('Seite löschen?')
+      .pipe(takeUntil(this.ngUnsubscribe))
+      .subscribe((result: boolean) => {
+        if (result) {
+          this.unitService.deletePage(page);
+          this.selectedPageIndex -= 1;
+        }
+      });
   }
 
   updateModel(page: UnitPage, property: string, value: number | boolean, isInputValid: boolean | null = true): void {
@@ -87,10 +89,6 @@ export class UnitViewComponent implements OnInit, OnDestroy {
     }
   }
 
-  showConfirmDialog(): Observable<boolean> {
-    return this.dialogService.showConfirmDialog();
-  }
-
   ngOnDestroy(): void {
     this.ngUnsubscribe.next();
     this.ngUnsubscribe.complete();
diff --git a/projects/editor/src/app/unit.service.ts b/projects/editor/src/app/unit.service.ts
index e7551a4b6..3507e8054 100644
--- a/projects/editor/src/app/unit.service.ts
+++ b/projects/editor/src/app/unit.service.ts
@@ -328,6 +328,7 @@ export class UnitService {
     }
   }
 
+  /* Silently ignores nonsense reorders! */
   private static moveArrayItem(item: unknown, array: unknown[], direction: 'up' | 'down'): void {
     const oldIndex = array.indexOf(item);
 
-- 
GitLab