chg: dev: refactor the code - there was unnecessary codes and wrongly formatted or designed code that are related to Repositories #7
This commit is contained in:
@@ -294,7 +294,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
|
||||
onSuccess: () => {
|
||||
showOverlay('Challenge accepted!', 'Waiting for the challenger to join...');
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
@@ -311,7 +311,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
|
||||
/>
|
||||
) : '');
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
@@ -457,7 +457,12 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
|
||||
/** Open event source after showing overlay */
|
||||
openEventSource();
|
||||
} else {
|
||||
await startMutation.mutateAsync();
|
||||
const startResponse = await startMutation.mutateAsync();
|
||||
if (!startResponse?.success) {
|
||||
showOverlay('Error', 'Failed to start game. Please try again.');
|
||||
isEnvDev && console.error('Start game failed:', startResponse);
|
||||
return;
|
||||
}
|
||||
openEventSource();
|
||||
wInit();
|
||||
}
|
||||
@@ -467,6 +472,7 @@ const useServerCommunication = (gameAssoc, gameInherited, opponentName, isEnvDev
|
||||
startHeartbeat();
|
||||
} catch (e) {
|
||||
isEnvDev && console.error('Connection error', e);
|
||||
showOverlay('Error', 'Connection failed. Please try again.');
|
||||
setTimeout(() => window.location.reload(), 500);
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user