From f8dbadc45bf87ba9a014a8bf1deb717f8ac70f93 Mon Sep 17 00:00:00 2001 From: lukas Date: Sat, 28 Aug 2021 22:21:51 +0200 Subject: [PATCH] player page: goback only if backstack available, go to homepage if not fix invalid api request when creating new actor --- src/elements/Popups/NewActorPopup/NewActorPopup.tsx | 8 ++++---- src/pages/Player/Player.tsx | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/elements/Popups/NewActorPopup/NewActorPopup.tsx b/src/elements/Popups/NewActorPopup/NewActorPopup.tsx index cce7387..6c38d95 100644 --- a/src/elements/Popups/NewActorPopup/NewActorPopup.tsx +++ b/src/elements/Popups/NewActorPopup/NewActorPopup.tsx @@ -22,7 +22,7 @@ class NewActorPopup extends React.Component { } export class NewActorPopupContent extends React.Component { - value: string | undefined; + nameValue: string | undefined; render(): JSX.Element { return ( @@ -32,7 +32,7 @@ export class NewActorPopupContent extends React.Component { type='text' placeholder='Actor Name' onChange={(v): void => { - this.value = v.target.value; + this.nameValue = v.target.value; }} /> @@ -48,11 +48,11 @@ export class NewActorPopupContent extends React.Component { */ storeselection(): void { // check if user typed in name - if (this.value === '' || this.value === undefined) { + if (this.nameValue === '' || this.nameValue === undefined) { return; } - callAPI(APINode.Actor, {action: 'createActor', actorname: this.value}, (result: GeneralSuccess) => { + callAPI(APINode.Actor, {action: 'createActor', ActorName: this.nameValue}, (result: GeneralSuccess) => { if (result.result !== 'success') { console.log('error occured while writing to db -- todo error handling'); console.log(result.result); diff --git a/src/pages/Player/Player.tsx b/src/pages/Player/Player.tsx index 82c86f8..c929d7e 100644 --- a/src/pages/Player/Player.tsx +++ b/src/pages/Player/Player.tsx @@ -314,7 +314,12 @@ export class Player extends React.Component { * calls callback to viewbinding to show previous page agains */ closebtn(): void { - this.props.history.goBack(); + const hist = this.props.history; + if (hist.length > 1) { + this.props.history.goBack(); + } else { + hist.push('/'); + } } /**