Skip to content

Commit 07ea45b

Browse files
authored
Remove deprecated synced block from GitBook Open (#2546)
1 parent a86d35f commit 07ea45b

File tree

7 files changed

+6
-127
lines changed

7 files changed

+6
-127
lines changed

.changeset/slimy-ravens-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gitbook': minor
3+
---
4+
5+
Remove deprecated synced block from GitBook Open

bun.lockb

392 Bytes
Binary file not shown.

packages/gitbook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static"
1717
},
1818
"dependencies": {
19-
"@gitbook/api": "^0.72.0",
19+
"@gitbook/api": "^0.73.0",
2020
"@gitbook/cache-do": "workspace:*",
2121
"@gitbook/emoji-codepoints": "workspace:*",
2222
"@gitbook/icons": "workspace:*",

packages/gitbook/src/components/DocumentView/Block.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
import { ClassValue } from '@/lib/tailwind';
1212

1313
import { BlockContentRef } from './BlockContentRef';
14-
import { BlockSyncedBlock } from './BlockSyncedBlock';
1514
import { CodeBlock } from './CodeBlock';
1615
import { Divider } from './Divider';
1716
import { DocumentContextProps } from './DocumentView';
@@ -107,8 +106,6 @@ export function Block<T extends DocumentBlock>(props: BlockProps<T>) {
107106
throw new Error('Blocks should be directly rendered by parent');
108107
case 'integration':
109108
return <IntegrationBlock {...props} block={block} />;
110-
case 'synced-block':
111-
return <BlockSyncedBlock {...props} block={block} />;
112109
case 'reusable-content':
113110
return <ReusableContent {...props} block={block} />;
114111
case 'stepper':
@@ -165,7 +162,6 @@ export function BlockSkeleton(props: { block: DocumentBlock; style: ClassValue }
165162
case 'content-ref':
166163
case 'integration':
167164
case 'stepper':
168-
case 'synced-block':
169165
case 'reusable-content':
170166
return <SkeletonCard id={id} style={style} />;
171167
case 'embed':

packages/gitbook/src/components/DocumentView/BlockSyncedBlock.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

packages/gitbook/src/lib/api.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -192,48 +192,6 @@ export const getUserById = cache({
192192
},
193193
});
194194

195-
/**
196-
* Get a synced block by its ref.
197-
*/
198-
export const getSyncedBlockContent = cache({
199-
name: 'api.getSyncedBlockContent',
200-
tag: (apiToken, organizationId, syncedBlockId) =>
201-
getAPICacheTag({
202-
tag: 'synced-block',
203-
syncedBlock: syncedBlockId,
204-
}),
205-
get: async (
206-
apiToken: string,
207-
organizationId: string,
208-
syncedBlockId: string,
209-
options: CacheFunctionOptions,
210-
) => {
211-
try {
212-
const response = await apiWithToken(apiToken).orgs.getSyncedBlockContent(
213-
organizationId,
214-
syncedBlockId,
215-
{
216-
...noCacheFetchOptions,
217-
signal: options.signal,
218-
},
219-
);
220-
return cacheResponse(response, {
221-
revalidateBefore: 60 * 60,
222-
});
223-
} catch (error) {
224-
if ((error as GitBookAPIError).code === 404) {
225-
return {
226-
revalidateBefore: 60 * 60,
227-
data: null,
228-
};
229-
}
230-
231-
throw error;
232-
}
233-
},
234-
// We don't cache apiToken as it's not a stable key
235-
getKeyArgs: (args) => [args[1], args[2]],
236-
});
237195
/**
238196
* Resolve a URL to the content to render.
239197
*/
@@ -1208,11 +1166,6 @@ export function getAPICacheTag(
12081166
tag: 'collection';
12091167
collection: string;
12101168
}
1211-
// All data related to a synced block
1212-
| {
1213-
tag: 'synced-block';
1214-
syncedBlock: string;
1215-
}
12161169
// All data related to a site
12171170
| {
12181171
tag: 'site';
@@ -1234,8 +1187,6 @@ export function getAPICacheTag(
12341187
return `space:${spec.space}:document:${spec.document}`;
12351188
case 'collection':
12361189
return `collection:${spec.collection}`;
1237-
case 'synced-block':
1238-
return `synced-block:${spec.syncedBlock}`;
12391190
case 'site':
12401191
return `site:${spec.site}`;
12411192
case 'integration':

packages/gitbook/src/lib/references.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ export async function resolveContentRef(
281281
reusableContent,
282282
};
283283
}
284-
case 'synced-block':
285-
return null;
286284

287285
default:
288286
assertNever(contentRef);
@@ -328,22 +326,3 @@ async function resolveContentRefInSpace(
328326
subText: space.title,
329327
};
330328
}
331-
332-
export function resolveContentRefWithFiles(
333-
files: RevisionFile[],
334-
contentRef: ContentRef,
335-
): ResolvedContentRef | null | undefined {
336-
if (contentRef.kind === 'file') {
337-
const file = files.find((file) => file.id === contentRef.file);
338-
if (file) {
339-
return {
340-
href: file.downloadURL,
341-
text: file.name,
342-
active: false,
343-
file,
344-
};
345-
}
346-
return null;
347-
}
348-
return undefined;
349-
}

0 commit comments

Comments
 (0)