|
|
@@ -12,6 +12,7 @@ import { useIdeReactContext } from '@/features/ide-react/context/ide-react-conte
|
|
|
import { useConnectionContext } from '@/features/ide-react/context/connection-context'
|
|
|
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
|
|
import { getJSON, postJSON } from '@/infrastructure/fetch-json'
|
|
|
+import { debugConsole } from '@/utils/debugging'
|
|
|
import { useOnlineUsersContext } from '@/features/ide-react/context/online-users-context'
|
|
|
import useSocketListener from '@/features/ide-react/hooks/use-socket-listener'
|
|
|
import useEventListener from '@/shared/hooks/use-event-listener'
|
|
|
@@ -92,14 +93,14 @@ export const MetadataProvider: FC<React.PropsWithChildren> = ({ children }) => {
|
|
|
}, [])
|
|
|
|
|
|
const loadProjectMetaFromServer = useCallback(() => {
|
|
|
- getJSON(`/project/${projectId}/metadata`).then(
|
|
|
- (response: { projectMeta: DocumentsMetadata }) => {
|
|
|
+ getJSON(`/project/${projectId}/metadata`)
|
|
|
+ .then((response: { projectMeta: DocumentsMetadata }) => {
|
|
|
const { projectMeta } = response
|
|
|
if (projectMeta) {
|
|
|
setDocuments(projectMeta)
|
|
|
}
|
|
|
- }
|
|
|
- )
|
|
|
+ })
|
|
|
+ .catch(debugConsole.error)
|
|
|
}, [projectId])
|
|
|
|
|
|
const loadDocMetaFromServer = useCallback(
|
|
|
@@ -111,13 +112,15 @@ export const MetadataProvider: FC<React.PropsWithChildren> = ({ children }) => {
|
|
|
body: {
|
|
|
broadcast,
|
|
|
},
|
|
|
- }).then((response: DocMetadataResponse) => {
|
|
|
- if (!broadcast && response) {
|
|
|
- // handle the POST response like a broadcast event when there are no
|
|
|
- // other users in the project.
|
|
|
- onBroadcastDocMeta(response)
|
|
|
- }
|
|
|
})
|
|
|
+ .then((response: DocMetadataResponse) => {
|
|
|
+ if (!broadcast && response) {
|
|
|
+ // handle the POST response like a broadcast event when there are no
|
|
|
+ // other users in the project.
|
|
|
+ onBroadcastDocMeta(response)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(debugConsole.error)
|
|
|
},
|
|
|
[onBroadcastDocMeta, onlineUsersCount, projectId]
|
|
|
)
|