🔥(clients) remove without_content query string

We now have a dedicated API to fetch only the doc
content, so we can remove the without_content
query string from the doc fetching API.
This commit is contained in:
Anthony LC
2026-04-10 13:40:31 +02:00
committed by Manuel Raynaud
parent 4c1175d825
commit ee8dd79247
6 changed files with 12 additions and 22 deletions

View File

@@ -18,7 +18,7 @@ export const LinkSelected = ({
isEditable,
onUpdateTitle,
}: LinkSelectedProps) => {
const { data: doc } = useDoc({ id: docId, withoutContent: true });
const { data: doc } = useDoc({ id: docId });
/**
* Update the content title if the referenced doc title changes

View File

@@ -6,15 +6,10 @@ import { Doc } from '../types';
export type DocParams = {
id: string;
withoutContent?: boolean;
};
export const getDoc = async ({
id,
withoutContent,
}: DocParams): Promise<Doc> => {
const params = withoutContent ? '?without_content=true' : '';
const response = await fetchAPI(`documents/${id}/${params}`);
export const getDoc = async ({ id }: DocParams): Promise<Doc> => {
const response = await fetchAPI(`documents/${id}/`);
if (!response.ok) {
throw new APIError('Failed to get the doc', await errorCauses(response));
@@ -24,7 +19,6 @@ export const getDoc = async ({
};
export const KEY_DOC = 'doc';
export const KEY_DOC_VISIBILITY = 'doc-visibility';
export function useDoc(
param: DocParams,

View File

@@ -19,13 +19,10 @@ describe('CollaborationBackend', () => {
const { fetchDocument } = await import('@/api/collaborationBackend');
const documentId = 'test-document-123';
await fetchDocument(
{ name: documentId, withoutContent: true },
{ cookie: 'test-cookie' },
);
await fetchDocument({ name: documentId }, { cookie: 'test-cookie' });
expect(axiosGetSpy).toHaveBeenCalledWith(
`http://app-dev:8000/api/v1.0/documents/${documentId}/?without_content=true`,
`http://app-dev:8000/api/v1.0/documents/${documentId}/`,
expect.objectContaining({
headers: expect.objectContaining({
'X-Y-Provider-Key': 'test-yprovider-key',

View File

@@ -228,7 +228,7 @@ describe('Server Tests', () => {
wsHocus.stopConnectionAttempt();
expect(data.reason).toBe('permission-denied');
expect(fetchDocumentMock).toHaveBeenCalledExactlyOnceWith(
{ name: room, withoutContent: true },
{ name: room },
expect.any(Object),
);
wsHocus.webSocket?.close();
@@ -273,7 +273,7 @@ describe('Server Tests', () => {
wsHocus.stopConnectionAttempt();
expect(data.reason).toBe('permission-denied');
expect(fetchDocumentMock).toHaveBeenCalledExactlyOnceWith(
{ name: room, withoutContent: true },
{ name: room },
expect.any(Object),
);
wsHocus.webSocket?.close();
@@ -322,7 +322,7 @@ describe('Server Tests', () => {
wsHocus.destroy();
expect(fetchDocumentMock).toHaveBeenCalledWith(
{ name: room, withoutContent: true },
{ name: room },
expect.any(Object),
);
@@ -371,7 +371,7 @@ describe('Server Tests', () => {
wsHocus.destroy();
expect(fetchDocumentMock).toHaveBeenCalledWith(
{ name: room, withoutContent: true },
{ name: room },
expect.any(Object),
);

View File

@@ -75,11 +75,10 @@ async function fetch<T>(
}
export function fetchDocument(
{ name, withoutContent }: { name: string; withoutContent?: boolean },
{ name }: { name: string },
requestHeaders: IncomingHttpHeaders,
): Promise<Doc> {
const params = withoutContent ? '?without_content=true' : '';
return fetch<Doc>(`/api/v1.0/documents/${name}/${params}`, requestHeaders);
return fetch<Doc>(`/api/v1.0/documents/${name}/`, requestHeaders);
}
export function fetchCurrentUser(

View File

@@ -40,7 +40,7 @@ export const hocuspocusServer = new Server({
try {
const document = await fetchDocument(
{ name: documentName, withoutContent: true },
{ name: documentName },
requestHeaders,
);