Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/api/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
CollectionData,
NotionSearchParamsType,
NotionSearchResultsType,
BlockType,
RecordMapType,
} from "./types";

const NOTION_API = "https://www.notion.so/api/v3";
Expand Down Expand Up @@ -126,8 +128,8 @@ export const fetchBlocks = async (
blockList: string[],
notionToken?: string
) => {
return await fetchNotionData<LoadPageChunkData>({
resource: "syncRecordValues",
const response = await fetchNotionData<{ results: BlockType[] }>({
resource: "getRecordValues",
body: {
requests: blockList.map((id) => ({
id,
Expand All @@ -137,6 +139,26 @@ export const fetchBlocks = async (
},
notionToken,
});

const recordMap: RecordMapType = {
block: {},
notion_user: {},
collection: {},
collection_view: {},
};

if (response.results) {
response.results.forEach((block) => {
recordMap.block[block.value.id] = block;
});
}

return {
recordMap,
cursor: {
stack: [],
},
} as LoadPageChunkData;
};

export const fetchNotionSearch = async (
Expand Down