From 2d2510e325a0531d64e7b60c842c9ff62f0b65df Mon Sep 17 00:00:00 2001
From: jojohoch <joachim.hoch@iqb.hu-berlin.de>
Date: Wed, 1 Dec 2021 14:53:57 +0100
Subject: [PATCH] [player] Change type of validPages

see Verona Api
---
 .../app/components/layout/layout.component.ts   | 17 ++++++++++-------
 .../player-state/player-state.component.ts      |  6 ++++--
 projects/player/src/app/models/verona.ts        |  2 +-
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/projects/player/src/app/components/layout/layout.component.ts b/projects/player/src/app/components/layout/layout.component.ts
index b3f043091..caa9222c5 100644
--- a/projects/player/src/app/components/layout/layout.component.ts
+++ b/projects/player/src/app/components/layout/layout.component.ts
@@ -21,7 +21,7 @@ export class LayoutComponent implements OnInit, OnDestroy {
   @Input() playerConfig!: PlayerConfig;
 
   @Output() selectedIndexChange = new EventEmitter<number>();
-  @Output() validPagesDetermined = new EventEmitter<Record<string, string>[]>();
+  @Output() validPagesDetermined = new EventEmitter<Record<string, string>>();
 
   private ngUnsubscribe = new Subject<void>();
 
@@ -65,12 +65,15 @@ export class LayoutComponent implements OnInit, OnDestroy {
     this.scrollPagesIndices = this.scrollPages.map(
       (scrollPage: Page): number => this.pages.indexOf(scrollPage)
     );
-    this.validPagesDetermined.emit(this.scrollPages.map((page: Page, index: number): Record<string, string> => (
-      {
-        [index.toString(10)]: `${this.translateService.instant('pageIndication', {
-          index: index + 1
-        })}`
-      })));
+    this.validPagesDetermined
+      .emit(this.scrollPages.reduce(
+        (validPages: Record<string, string>, page: Page, index: number) => ({
+          ...validPages,
+          [`page${index + 1}`]: `${this.translateService.instant(
+            'pageIndication', { index: index + 1 }
+          )}`
+        }), {}
+      ));
   }
 
   private initLayout(): void {
diff --git a/projects/player/src/app/components/player-state/player-state.component.ts b/projects/player/src/app/components/player-state/player-state.component.ts
index 718e3a15b..bbd306edd 100644
--- a/projects/player/src/app/components/player-state/player-state.component.ts
+++ b/projects/player/src/app/components/player-state/player-state.component.ts
@@ -25,7 +25,7 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
   currentPlayerPageIndex: number = 0;
   selectIndex: Subject<number> = new Subject();
   running: boolean = true;
-  validPages!: Record<string, string> [];
+  validPages!: Record<string, string>;
 
   private ngUnsubscribe = new Subject<void>();
 
@@ -60,7 +60,7 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
     this.sendVopStateChangedNotification();
   }
 
-  onValidPagesDetermined(validPages: Record<string, string>[]): void {
+  onValidPagesDetermined(validPages: Record<string, string>): void {
     this.validPages = validPages;
     this.sendVopStateChangedNotification();
   }
@@ -100,6 +100,8 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
       currentPage: this.currentPlayerPageIndex.toString(10),
       validPages: this.validPages
     };
+    // eslint-disable-next-line no-console
+    console.log('player: playerState sendVopStateChangedNotification', playerState);
     this.veronaPostService.sendVopStateChangedNotification({ playerState }, requested);
   }
 
diff --git a/projects/player/src/app/models/verona.ts b/projects/player/src/app/models/verona.ts
index 6d991346d..b1aa1db02 100644
--- a/projects/player/src/app/models/verona.ts
+++ b/projects/player/src/app/models/verona.ts
@@ -43,7 +43,7 @@ export interface UnitState {
 
 export interface PlayerState {
   state: RunningState;
-  validPages?: Record<string, string>[];
+  validPages?: Record<string, string>;
   currentPage?: string;
 }
 
-- 
GitLab