gwchq-textjam 0.2.24 → 0.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +25 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -368757,7 +368757,7 @@ const TextJamEditor = ({ onLogoutClick = () => { }, onViewProfileClick = () => {
368757
368757
  if (!store || !navigationGuardCoordinator)
368758
368758
  return;
368759
368759
  const guardController = new LeaveGuardController_1.LeaveGuardController(store);
368760
- const unsubscribe = navigationGuardCoordinator.register(guardController.canLeave);
368760
+ const unsubscribe = navigationGuardCoordinator.register(guardController.canLeave, guardController.shouldBlock);
368761
368761
  return () => {
368762
368762
  guardController?.cleanup();
368763
368763
  unsubscribe?.();
@@ -373943,6 +373943,12 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
373943
373943
  if (!hasContentChanges && !hasNameChanges && !isInitialSave) {
373944
373944
  dispatch((0, EditorSlice_1.setSaveTriggered)(false));
373945
373945
  dispatch((0, EditorSlice_1.setSaving)(types_1.SavingState.IDLE));
373946
+ // If we got here from the Save-in-modal path, resolve the leave flow
373947
+ // so the pending navigation isn't stuck on a no-op save.
373948
+ if (leaveFlow.requestId &&
373949
+ leaveFlow.status === LeaveFlowSlice_1.LeaveFlowStatus.SAVING) {
373950
+ dispatch((0, LeaveFlowSlice_1.leaveConfirmed)({ requestId: leaveFlow.requestId }));
373951
+ }
373946
373952
  console.warn("No changes detected. Save won't be processed.");
373947
373953
  return;
373948
373954
  }
@@ -373966,6 +373972,14 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
373966
373972
  (0, sendToast_1.showError)(`The project exceeds the ${constants_1.MAX_PROJECT_TOTAL_SIZE_MB} MB maximum allowed size. Please reduce the project size to save successfully.`);
373967
373973
  dispatch((0, EditorSlice_1.setSaveTriggered)(false));
373968
373974
  dispatch((0, EditorSlice_1.setSaving)(types_1.SavingState.IDLE));
373975
+ // Surface the failure to a pending leave flow so the modal doesn't get stuck
373976
+ if (leaveFlow.requestId &&
373977
+ leaveFlow.status === LeaveFlowSlice_1.LeaveFlowStatus.SAVING) {
373978
+ dispatch((0, LeaveFlowSlice_1.saveFailed)({
373979
+ requestId: leaveFlow.requestId,
373980
+ error: "Project size exceeds the maximum allowed size.",
373981
+ }));
373982
+ }
373969
373983
  return;
373970
373984
  }
373971
373985
  await saveProject?.({
@@ -373991,6 +374005,7 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
373991
374005
  project.identifier,
373992
374006
  hasContentChanges,
373993
374007
  hasNameChanges,
374008
+ leaveFlow.requestId,
373994
374009
  leaveFlow.status,
373995
374010
  ]);
373996
374011
  // finish the process if save failed
@@ -374026,6 +374041,9 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
374026
374041
  });
374027
374042
  const incomingCommitId = projectData?.commitId;
374028
374043
  const incomingIdentifier = projectData?.identifier;
374044
+ dispatch((0, EditorSlice_1.setSaveTriggered)(false));
374045
+ if (leaveFlow.requestId && leaveFlow.status === LeaveFlowSlice_1.LeaveFlowStatus.SAVING)
374046
+ dispatch((0, LeaveFlowSlice_1.leaveConfirmed)({ requestId: leaveFlow.requestId }));
374029
374047
  if (!incomingIdentifier)
374030
374048
  return;
374031
374049
  // first save: new commitId incoming, but no commitId were set before
@@ -374047,10 +374065,6 @@ const useProjectPersistence = ({ user, projectData, hasShownSavePrompt, saveProj
374047
374065
  dispatch((0, EditorSlice_1.updateProjectIdentifier)(projectData.identifier));
374048
374066
  deleteValueFromCache(project.identifier);
374049
374067
  }
374050
- dispatch((0, EditorSlice_1.setSaveTriggered)(false));
374051
- // if the save was triggered by the leave flow, mark it as completed to allow the flow to proceed
374052
- if (leaveFlow.requestId && leaveFlow.status === LeaveFlowSlice_1.LeaveFlowStatus.SAVING)
374053
- dispatch((0, LeaveFlowSlice_1.leaveConfirmed)({ requestId: leaveFlow.requestId }));
374054
374068
  // Build new snapshot after save (remove isDirty from components, reset file structure, update identifier)
374055
374069
  const cleanedComponents = project.components.map(({ isDirty, ...rest }) => rest);
374056
374070
  const cleanedProject = {
@@ -375401,6 +375415,12 @@ class LeaveGuardController {
375401
375415
  constructor(store) {
375402
375416
  this.store = store;
375403
375417
  }
375418
+ // Returning false here lets useRouteGuard short-circuit and allow native
375419
+ // POP/PUSH for clean states without async work or a modal.
375420
+ shouldBlock = () => {
375421
+ const state = this.store.getState();
375422
+ return (0, selectors_1.selectProjectDirtyState)(state);
375423
+ };
375404
375424
  canLeave = () => {
375405
375425
  const state = this.store.getState();
375406
375426
  const isDirty = (0, selectors_1.selectProjectDirtyState)(state);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gwchq-textjam",
3
3
  "description": "Embeddable React editor used in Raspberry Pi text-based projects.",
4
- "version": "0.2.24",
4
+ "version": "0.2.25",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/GirlsFirst/gwchq-textjam",
7
7
  "author": "Girls Who Code HQ",