@react-remote-state/client 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -5559,7 +5559,7 @@ function wrapReducer(reducer) {
5559
5559
  }
5560
5560
  };
5561
5561
  }
5562
- function useRemoteReducer(uri, reducer, gameId) {
5562
+ function useRemoteReducer(uri, reducer, gameId, storage = sessionStorage) {
5563
5563
  let [meta, setMeta] = useState({
5564
5564
  isHostReady: false,
5565
5565
  isGuestReady: false
@@ -5585,7 +5585,7 @@ function useRemoteReducer(uri, reducer, gameId) {
5585
5585
  (_a = meta.client) == null ? void 0 : _a.emit("create");
5586
5586
  } else if (!!gameId) {
5587
5587
  let playerCache = (0, import_lodash.flow)(
5588
- () => !!gameId ? sessionStorage.getItem(gameId) : null,
5588
+ () => !!gameId ? storage.getItem(gameId) : null,
5589
5589
  (cache) => !!cache ? JSON.parse(cache) : null
5590
5590
  )();
5591
5591
  if (!!playerCache) {
@@ -5603,12 +5603,12 @@ function useRemoteReducer(uri, reducer, gameId) {
5603
5603
  meta.client.on("assign", (assign) => {
5604
5604
  var _a, _b;
5605
5605
  setMeta(__spreadProps(__spreadValues({}, meta), { localPlayerId: assign.playerId }));
5606
- if (!!((_a = meta == null ? void 0 : meta.client) == null ? void 0 : _a.id) && !!(game == null ? void 0 : game.id)) {
5606
+ if (!!((_a = meta == null ? void 0 : meta.client) == null ? void 0 : _a.id)) {
5607
5607
  let playerCache = {
5608
5608
  playerId: assign.playerId,
5609
5609
  socketId: (_b = meta.client) == null ? void 0 : _b.id
5610
5610
  };
5611
- sessionStorage.setItem(game.id, JSON.stringify(playerCache));
5611
+ storage.setItem(assign.gameId, JSON.stringify(playerCache));
5612
5612
  }
5613
5613
  });
5614
5614
  meta.client.on(