diff --git a/ui/src/Game.tsx b/ui/src/Game.tsx
index 29e7630..4918963 100644
--- a/ui/src/Game.tsx
+++ b/ui/src/Game.tsx
@@ -134,7 +134,7 @@ export function Game(props: {
})
.catch((error) => {
console.error({error});
- //logDispatch(
{error}
);
+ logDispatch({error}
);
});
}
@@ -511,7 +511,7 @@ export function Game(props: {
})
}}/>);
} else {
- //logDispatch({error}
);
+ logDispatch({error}
);
}
@@ -539,7 +539,7 @@ export function Game(props: {
})
.catch((error) => {
console.error({error});
- //logDispatch({error}
);
+ logDispatch({error}
);
});
}
}}>Pass
diff --git a/ui/src/ws_api.tsx b/ui/src/ws_api.tsx
index d3721dd..e7697d4 100644
--- a/ui/src/ws_api.tsx
+++ b/ui/src/ws_api.tsx
@@ -77,6 +77,7 @@ export type ClientToServerMessage = {
interface PromiseInput {
resolve: (value: GameEvent) => void
reject: (error: any) => void
+ type: string // recorded for debug purposes
}
export class WSAPI implements API{
@@ -110,20 +111,27 @@ export class WSAPI implements API{
});
}
- private register_promise(resolve: (value: GameEvent) => void, reject: (value: any) => void) {
+ private register_promise(resolve: (value: GameEvent) => void, reject: (value: any) => void, type: string) {
+ const newPromise = {
+ resolve: resolve,
+ reject: reject,
+ type: type,
+ };
+
if(this.currentPromiseInput != null) {
console.error("We are setting a new promise before the current one has resolved")
- this.currentPromiseInput.reject("New promise was registered");
+ console.error("Current promise: ", this.currentPromiseInput);
+ console.error("New promise: ", newPromise);
+
+ // Some of the rejects take statements from the server and log them; maybe don't send this to reject
+ //this.currentPromiseInput.reject("New promise was registered");
}
- this.currentPromiseInput = {
- resolve: resolve,
- reject: reject
- };
+ this.currentPromiseInput = newPromise;
}
add_to_dictionary(word: string): Promise {
return new Promise((resolve, reject) => {
- this.register_promise(resolve, reject);
+ this.register_promise(resolve, reject, "AddToDictionary");
let event: ClientToServerMessage = {
type: "GameMove",
move: {
@@ -140,7 +148,7 @@ export class WSAPI implements API{
exchange(selection: Array): Promise {
return new Promise((resolve, reject) => {
- this.register_promise(resolve, reject);
+ this.register_promise(resolve, reject, "Exchange");
let event: ClientToServerMessage = {
type: "GameMove",
move: {
@@ -156,7 +164,7 @@ export class WSAPI implements API{
load(wait: boolean): Promise {
return new Promise((resolve, reject) => {
- this.register_promise(resolve, reject);
+ this.register_promise(resolve, reject, `Load with wait=${wait}`);
if(!wait) {
let event: ClientToServerMessage = {
type: "Load"
@@ -170,7 +178,7 @@ export class WSAPI implements API{
pass(): Promise {
return new Promise((resolve, reject) => {
- this.register_promise(resolve, reject);
+ this.register_promise(resolve, reject, "Pass");
let event: ClientToServerMessage = {
type: "GameMove",
move: {
@@ -185,7 +193,7 @@ export class WSAPI implements API{
play(tiles: Array, commit: boolean): Promise {
return new Promise((resolve, reject) => {
- this.register_promise(resolve, reject);
+ this.register_promise(resolve, reject, "Play");
let event: ClientToServerMessage = {
type: "GameMove",
move: {