From 0ca91d26af2bddfaf0afaaafade9ef303605537b Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Thu, 3 Aug 2023 10:43:59 -0400 Subject: [PATCH] Merge pull request #14110 from overleaf/jdt-editor-left-main-doc-refresh fix: updating context with new root doc id GitOrigin-RevId: 87e803554efc20cce4404f4f0f4137ae7fe9c2aa --- .../features/editor-left-menu/hooks/use-root-doc-id.tsx | 2 +- .../editor-left-menu/hooks/use-save-project-settings.tsx | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx b/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx index 31a5e7e4a2..ca2e85841f 100644 --- a/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx +++ b/services/web/frontend/js/features/editor-left-menu/hooks/use-root-doc-id.tsx @@ -12,7 +12,7 @@ export default function useRootDocId() { const setRootDocIdFunc = useCallback( async (newRootDocId: ProjectSettings['rootDocId']) => { - // rootDoc_id will be undefined on angular scope on initialisation + // rootDocId will be undefined on angular scope on initialisation const allowUpdate = typeof rootDocId !== 'undefined' && permissionsLevel !== 'readOnly' diff --git a/services/web/frontend/js/features/editor-left-menu/hooks/use-save-project-settings.tsx b/services/web/frontend/js/features/editor-left-menu/hooks/use-save-project-settings.tsx index 6af0a180c9..e4f41271b4 100644 --- a/services/web/frontend/js/features/editor-left-menu/hooks/use-save-project-settings.tsx +++ b/services/web/frontend/js/features/editor-left-menu/hooks/use-save-project-settings.tsx @@ -15,13 +15,17 @@ export default function useSaveProjectSettings() { ) => { if (projectSettings) { const currentSetting = projectSettings[key] - if (currentSetting !== newSetting) { await saveProjectSettings(projectId, { [key]: newSetting, }) - setProjectSettings({ ...projectSettings, [key]: newSetting }) + // rootDocId is used in our tsx and our endpoint, but rootDoc_id is used in our project $scope, etc + // as we use both namings in many files, and convert back and forth, + // its complicated to seperate and choose one name for all usages + // todo: make rootDocId or rootDoc_id consistent, and remove need for this/ other conversions + const settingsKey = key === 'rootDocId' ? 'rootDoc_id' : key + setProjectSettings({ ...projectSettings, [settingsKey]: newSetting }) } } }