瀏覽代碼

Update LinkedGame to pass old game settings to GCF

Kirk Trombley 4 年之前
父節點
當前提交
819a027942

+ 19 - 11
client/src/components/screens/GameSummary/LinkedGame.jsx

@@ -2,16 +2,24 @@ import React from "react";
 import { linkGame } from "../../../domain/apiMethods";
 import { dispatch } from "../../../domain/gameStore";
 import GameCreationForm from "../../util/GameCreationForm";
+import { useGameConfig } from "../../../hooks/useGameInfo";
 import styles from "./GameSummary.module.css";
 
-export default React.memo(({ linkedGame, gameId }) => (
-  <div className={styles.linked}>
-    {linkedGame ? (
-      <button onClick={() => dispatch.goToLobby(linkedGame)} type="button">
-        Continue to Linked Game Lobby
-      </button>
-    ) : (
-      <GameCreationForm afterCreate={linkId => linkGame(gameId, linkId)} />
-    )}
-  </div>
-));
+export default React.memo(({ linkedGame, gameId }) => {
+  const lastSettings = useGameConfig();
+
+  return (
+    <div className={styles.linked}>
+      {linkedGame ? (
+        <button onClick={() => dispatch.goToLobby(linkedGame)} type="button">
+          Continue to Linked Game Lobby
+        </button>
+      ) : (
+        <GameCreationForm
+          afterCreate={linkId => linkGame(gameId, linkId)}
+          lastSettings={lastSettings}
+        />
+      )}
+    </div>
+  );
+});

+ 1 - 0
client/src/tests/__snapshots__/LinkedGame.test.js.snap

@@ -19,6 +19,7 @@ exports[`LinkedGame renders with no linked game 1`] = `
 >
   <GameCreationForm
     afterCreate={[Function]}
+    lastSettings={Object {}}
   />
 </div>
 `;