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 ca2e85841f..8a704f87ac 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 @@ -6,7 +6,7 @@ import useSaveProjectSettings from './use-save-project-settings' export default function useRootDocId() { const [rootDocId] = - useScopeValue('project.rootDoc_id') + useScopeValue('project.rootDocId') const { permissionsLevel } = useEditorContext() const saveProjectSettings = useSaveProjectSettings() 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 07a20a10fa..f34c506708 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 @@ -19,13 +19,7 @@ export default function useSaveProjectSettings() { await saveProjectSettings(projectId, { [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 }) + setProjectSettings({ ...projectSettings, [key]: newSetting }) } } } diff --git a/services/web/frontend/js/features/ide-react/context/ide-react-context.tsx b/services/web/frontend/js/features/ide-react/context/ide-react-context.tsx index 25ef9cc0d6..51ecbdc6c9 100644 --- a/services/web/frontend/js/features/ide-react/context/ide-react-context.tsx +++ b/services/web/frontend/js/features/ide-react/context/ide-react-context.tsx @@ -127,10 +127,11 @@ export const IdeReactProvider: FC = ({ children }) => { // Populate scope values when joining project, then fire project:joined event useEffect(() => { function handleJoinProjectResponse({ - project, + project: { rootDoc_id: rootDocId, ..._project }, permissionsLevel, }: JoinProjectPayload) { - scopeStore.set('project', { rootDoc_id: null, ...project }) + const project = { ..._project, rootDocId } + scopeStore.set('project', project) scopeStore.set('permissionsLevel', permissionsLevel) // Make watchers update immediately scopeStore.flushUpdates() diff --git a/services/web/frontend/js/shared/context/project-context.tsx b/services/web/frontend/js/shared/context/project-context.tsx index bd9ee12fdb..f294a88021 100644 --- a/services/web/frontend/js/shared/context/project-context.tsx +++ b/services/web/frontend/js/shared/context/project-context.tsx @@ -36,7 +36,7 @@ export const ProjectProvider: FC = ({ children }) => { compiler, imageName, name, - rootDoc_id: rootDocId, + rootDocId, members, invites, features, diff --git a/services/web/frontend/stories/decorators/scope.tsx b/services/web/frontend/stories/decorators/scope.tsx index 3be1db9de5..31f38c79f4 100644 --- a/services/web/frontend/stories/decorators/scope.tsx +++ b/services/web/frontend/stories/decorators/scope.tsx @@ -41,7 +41,7 @@ const project: Project = { }, members: [], invites: [], - rootDoc_id: '5e74f1a7ce17ae0041dfd056', + rootDocId: '5e74f1a7ce17ae0041dfd056', rootFolder: [ { _id: 'root-folder-id', diff --git a/services/web/test/frontend/helpers/editor-providers.jsx b/services/web/test/frontend/helpers/editor-providers.jsx index bdff189975..645b29fb64 100644 --- a/services/web/test/frontend/helpers/editor-providers.jsx +++ b/services/web/test/frontend/helpers/editor-providers.jsx @@ -103,7 +103,7 @@ export function EditorProviders({ name: PROJECT_NAME, owner: projectOwner, features: projectFeatures, - rootDoc_id: rootDocId, + rootDocId, rootFolder, imageName, compiler, diff --git a/services/web/types/project.ts b/services/web/types/project.ts index 83a28533b3..0fc21533e2 100644 --- a/services/web/types/project.ts +++ b/services/web/types/project.ts @@ -25,7 +25,8 @@ export type Project = { owner: MongoUser members: ProjectMember[] invites: ProjectInvite[] - rootDoc_id?: string + // `rootDoc_id` in the backend; `rootDocId` in the frontend + rootDocId?: string rootFolder?: Folder[] deletedByExternalDataSource?: boolean }