gwchq-textjam 0.1.82 → 0.1.83

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 +41 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -371948,7 +371948,7 @@ const createProjectArchive_1 = __webpack_require__(46514);
371948
371948
  const Loading_1 = __importDefault(__webpack_require__(34466));
371949
371949
  const stores_1 = __webpack_require__(32132);
371950
371950
  const WebComponentLoader = (props) => {
371951
- const { locale = "en", projectNameEditable = true, readOnly = false, sidebarOptions = [], loadCache = true, project: projectData, saveProject, isSaving, loadCommit = (commitId) => { }, commits = [], projectContent = null, isLoading = false, packageApiUrl, user, getTextJamTemplate, template, isCodeVisible = true, isSharedProject = false, shareLinks, } = props;
371951
+ const { locale = "en", projectNameEditable = true, readOnly = false, sidebarOptions = [], loadCache = true, project: projectData, saveProject, isSaving, loadCommit, commits = [], projectContent = null, isLoading = false, packageApiUrl, user, getTextJamTemplate, template, isCodeVisible = true, isSharedProject = false, shareLinks, } = props;
371952
371952
  const dispatch = (0, react_redux_1.useDispatch)();
371953
371953
  const { t } = (0, react_i18next_1.useTranslation)();
371954
371954
  const project = (0, stores_1.useAppSelector)((state) => state.editor.project);
@@ -371972,7 +371972,8 @@ const WebComponentLoader = (props) => {
371972
371972
  dispatch((0, EditorSlice_1.setCommits)({ commits }));
371973
371973
  }, [commits, dispatch]);
371974
371974
  (0, react_1.useEffect)(() => {
371975
- dispatch((0, EditorSlice_1.setLoadCommit)({ loadCommit }));
371975
+ if (loadCommit)
371976
+ dispatch((0, EditorSlice_1.setLoadCommit)({ loadCommit }));
371976
371977
  }, [loadCommit, dispatch]);
371977
371978
  (0, react_1.useEffect)(() => {
371978
371979
  if (shareLinks)
@@ -372027,6 +372028,7 @@ const WebComponentLoader = (props) => {
372027
372028
  saveTriggered,
372028
372029
  onSave,
372029
372030
  user,
372031
+ isShared: isSharedProject,
372030
372032
  });
372031
372033
  (0, react_1.useEffect)(() => {
372032
372034
  dispatch((0, EditorSlice_1.setReadOnly)(readOnly));
@@ -372676,7 +372678,8 @@ const useProject = ({ loadCache = true, identifier = null, projectData = null, t
372676
372678
  try {
372677
372679
  let currentIndexDb = null;
372678
372680
  try {
372679
- currentIndexDb = await IndexedDb_1.IndexedDb.getProject(project.identifier) ?? null;
372681
+ currentIndexDb =
372682
+ (await IndexedDb_1.IndexedDb.getProject(project.identifier)) ?? null;
372680
372683
  }
372681
372684
  catch (e) { }
372682
372685
  const currentCommit = commits.find((item) => item.id === projectData.commitId) ?? null;
@@ -372686,7 +372689,8 @@ const useProject = ({ loadCache = true, identifier = null, projectData = null, t
372686
372689
  !!projectData.commitId &&
372687
372690
  !!currentIndexDb &&
372688
372691
  !currentIndexDb?.commitId &&
372689
- !!projectContent) { //"Project was saved first time. Copy database. Remove old version from database"
372692
+ !!projectContent) {
372693
+ //"Project was saved first time. Copy database. Remove old version from database"
372690
372694
  setAppliedCommit(projectData.commitId ?? null);
372691
372695
  const loaded = {
372692
372696
  ...currentIndexDb,
@@ -372700,18 +372704,27 @@ const useProject = ({ loadCache = true, identifier = null, projectData = null, t
372700
372704
  //remove old project
372701
372705
  await IndexedDb_1.IndexedDb.deleteProject(project.identifier);
372702
372706
  }
372703
- else if ((!project.identifier || projectData.identifier === project.identifier) &&
372707
+ else if ((!project.identifier ||
372708
+ projectData.identifier === project.identifier) &&
372704
372709
  !!projectData.commitId &&
372705
372710
  (!project.commitId || project.commitId === projectData.commitId) &&
372706
372711
  !!currentCommit &&
372707
- !appliedCommit) { // Handling commit loading when the project is accessed directly via a URL
372708
- const savedAtDate = currentIndexDb?.savedAt ? new Date(currentIndexDb.savedAt) : null;
372712
+ !appliedCommit) {
372713
+ // Handling commit loading when the project is accessed directly via a URL
372714
+ const savedAtDate = currentIndexDb?.savedAt
372715
+ ? new Date(currentIndexDb.savedAt)
372716
+ : null;
372709
372717
  const currentCommitDate = new Date(currentCommit.createdAt);
372710
- const isCommitLater = savedAtDate ? savedAtDate < currentCommitDate : true;
372711
- if ((!currentIndexDb || !currentIndexDb.commitId || isCommitLater) && !projectContent) { // The commit is newer than the cached version, so load the latest commit
372718
+ const isCommitLater = savedAtDate
372719
+ ? savedAtDate < currentCommitDate
372720
+ : true;
372721
+ if ((!currentIndexDb || !currentIndexDb.commitId || isCommitLater) &&
372722
+ !projectContent) {
372723
+ // The commit is newer than the cached version, so load the latest commit
372712
372724
  loadCommit?.(projectData.commitId);
372713
372725
  }
372714
- else if (!!projectContent) { // Commit data has been loaded, now apply it to the project state
372726
+ else if (!!projectContent) {
372727
+ // Commit data has been loaded, now apply it to the project state
372715
372728
  const identifier = projectData.identifier;
372716
372729
  const { components, rootDirId } = await (0, loadProjectFromZip_1.loadProjectFromZip)({
372717
372730
  zipBlob: projectContent,
@@ -372799,9 +372812,10 @@ const useProject = ({ loadCache = true, identifier = null, projectData = null, t
372799
372812
  return;
372800
372813
  // in case no identifier and no cached project, or provided identifier doesn't match cached project,
372801
372814
  // create default project
372802
- const defaultProject = template?.data ?? (projectData?.project_type === ProjectTypes_1.ProjectType.WEB
372803
- ? (0, defaultProjects_1.createDefaultWebProject)()
372804
- : (0, defaultProjects_1.createDefaultPythonProject)());
372815
+ const defaultProject = template?.data ??
372816
+ (projectData?.project_type === ProjectTypes_1.ProjectType.WEB
372817
+ ? (0, defaultProjects_1.createDefaultWebProject)()
372818
+ : (0, defaultProjects_1.createDefaultPythonProject)());
372805
372819
  // if no identifier is provided, generate basic project
372806
372820
  if (!identifier) {
372807
372821
  dispatch((0, EditorSlice_1.setProject)(defaultProject));
@@ -372825,7 +372839,15 @@ const useProject = ({ loadCache = true, identifier = null, projectData = null, t
372825
372839
  return;
372826
372840
  }
372827
372841
  // eslint-disable-next-line react-hooks/exhaustive-deps
372828
- }, [project?.identifier, cachedProject, cacheLoaded, i18n.language, template, templateId, projectContent]);
372842
+ }, [
372843
+ project?.identifier,
372844
+ cachedProject,
372845
+ cacheLoaded,
372846
+ i18n.language,
372847
+ template,
372848
+ templateId,
372849
+ projectContent,
372850
+ ]);
372829
372851
  };
372830
372852
  exports.useProject = useProject;
372831
372853
 
@@ -372846,7 +372868,7 @@ const Notifications_1 = __webpack_require__(73606);
372846
372868
  const IndexedDb_1 = __webpack_require__(27161);
372847
372869
  const ProjectTypes_1 = __webpack_require__(27130);
372848
372870
  const COMBINED_FILE_SIZE_SOFT_LIMIT = 1000000;
372849
- const useProjectPersistence = ({ user, project, justLoaded, hasShownSavePrompt, saveTriggered, onSave, }) => {
372871
+ const useProjectPersistence = ({ user, project, justLoaded, hasShownSavePrompt, saveTriggered, onSave, isShared, }) => {
372850
372872
  const dispatch = (0, react_redux_1.useDispatch)();
372851
372873
  const combinedFileSize = project?.components?.reduce((sum, component) => {
372852
372874
  if (component.type !== ProjectTypes_1.ProjectComponentType.FILE) {
@@ -372882,7 +372904,10 @@ const useProjectPersistence = ({ user, project, justLoaded, hasShownSavePrompt,
372882
372904
  dispatch((0, EditorSlice_1.expireJustLoaded)());
372883
372905
  }
372884
372906
  else {
372885
- if (!hasShownSavePrompt && user && (0, projectHelpers_1.isOwner)(user, project)) {
372907
+ if (!hasShownSavePrompt &&
372908
+ user &&
372909
+ (0, projectHelpers_1.isOwner)(user, project) &&
372910
+ !isShared) {
372886
372911
  (0, Notifications_1.showSavePrompt)();
372887
372912
  dispatch((0, EditorSlice_1.setHasShownSavePrompt)());
372888
372913
  }
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.1.82",
4
+ "version": "0.1.83",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/GirlsFirst/gwchq-textjam",
7
7
  "author": "Girls Who Code HQ",