Skip to content

Commit

Permalink
Refactor IndexPaperCard and ReferenceMapList components
Browse files Browse the repository at this point in the history
  • Loading branch information
Anoop K. Chandran committed Dec 23, 2023
1 parent 787eb42 commit 2c60dfe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/components/IndexPaperCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ReferenceMap from 'src/main'
type IndexCardsProps = {
className?: string
plugin: ReferenceMap
rootPaper: IndexPaper
indexPaper: IndexPaper
viewManager: ViewManager
}

Expand All @@ -27,11 +27,11 @@ export const IndexPaperCard = (props: IndexCardsProps) => {
const { settings } = props.plugin

useEffect(() => {
if (props.rootPaper.paper.paperId && !props.rootPaper.isLocal) {
if (props.indexPaper.paper.paperId && !props.indexPaper.isLocal) {
getCitations()
getReferences()
}
}, [props.rootPaper.isLocal])
}, [props.indexPaper.isLocal])

useEffect(() => {
setIsButtonShown(!settings.hideButtonsOnHover)
Expand All @@ -47,7 +47,7 @@ export const IndexPaperCard = (props: IndexCardsProps) => {

const getReferences = async () => {
setIsReferenceLoading(true);
const references = await props.viewManager.getReferences(props.rootPaper.paper.paperId);
const references = await props.viewManager.getReferences(props.indexPaper.paper.paperId);
const filteredReferences = settings.filterRedundantReferences
? references.filter((reference) => (reference.referenceCount && reference.referenceCount > 0) || (reference.citationCount && reference.citationCount > 0))
: references;
Expand All @@ -57,7 +57,7 @@ export const IndexPaperCard = (props: IndexCardsProps) => {

const getCitations = async () => {
setIsCitationLoading(true);
const citations = await props.viewManager.getCitations(props.rootPaper.paper.paperId);
const citations = await props.viewManager.getCitations(props.indexPaper.paper.paperId);
const filteredCitations = settings.filterRedundantReferences
? citations.filter((citation) => (citation.referenceCount && citation.referenceCount > 0) || (citation.citationCount && citation.citationCount > 0))
: citations;
Expand Down Expand Up @@ -87,11 +87,11 @@ export const IndexPaperCard = (props: IndexCardsProps) => {
onMouseEnter={() => handleHoverButtons(true)}
onMouseLeave={() => handleHoverButtons(false)}
>
<PaperHeading paper={props.rootPaper} settings={settings} />
<PaperHeading paper={props.indexPaper} settings={settings} />
{isButtonShown && (
<PaperButtons
settings={settings}
paper={props.rootPaper}
paper={props.indexPaper}
setShowReferences={setShowReferences}
showReferences={showReferences}
setShowCitations={setShowCitations}
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/ReferenceMapList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const ReferenceMapList = (props: {
<IndexPaperCard
className={activeIndexCardClass}
plugin={props.plugin}
rootPaper={paper}
indexPaper={paper}
viewManager={viewManager}
/>
</div>
Expand Down

0 comments on commit 2c60dfe

Please sign in to comment.