|
6 | 6 | fetchFromSemanticScholar, |
7 | 7 | addToNotionDatabase, |
8 | 8 | updateNotionPage, |
| 9 | + fetchNotionBlock, |
9 | 10 | } from './utils'; |
10 | 11 | import { SearchIcon } from '@public/icons'; |
11 | 12 | import { Loading } from '@components/atoms'; |
@@ -73,15 +74,22 @@ export default function Search({ |
73 | 74 | const referencesScidSet = new Set(paper.references?.map(ref => ref.scid)) |
74 | 75 | const citationsScidSet = new Set(paper.citations?.map(ref => ref.scid)) |
75 | 76 | for (const notionPaper of knownPapers) { |
| 77 | + if (notionPaper.citationScids === undefined || notionPaper.referenceScids === undefined) { |
| 78 | + const fetchedPaper = await fetchNotionBlock(notionPaper.id) |
| 79 | + notionPaper.abstract = fetchedPaper.abstract |
| 80 | + notionPaper.citationScids = fetchedPaper.citationScids |
| 81 | + notionPaper.referenceScids = fetchedPaper.referenceScids |
| 82 | + } |
| 83 | + |
76 | 84 | if (referencesScidSet.has(notionPaper.scid) |
77 | | - || notionPaper.citationScids.includes(paper.scid)) { |
| 85 | + || notionPaper.citationScids?.includes(paper.scid)) { |
78 | 86 | await updateNotionPage(notionPaper.id, { |
79 | 87 | citations: [...(notionPaper.citations ?? []), { id: returnedPaper.id }], |
80 | 88 | }) |
81 | 89 | returnedPaper.references?.push({ id: notionPaper.id } as any) |
82 | 90 | } |
83 | 91 | if (citationsScidSet.has(notionPaper.scid) |
84 | | - || notionPaper.referenceScids.includes(paper.scid)) { |
| 92 | + || notionPaper.referenceScids?.includes(paper.scid)) { |
85 | 93 | await updateNotionPage(notionPaper.id, { |
86 | 94 | references: [...(notionPaper.references ?? []), { id: returnedPaper.id }], |
87 | 95 | }) |
|
0 commit comments