diff options
| author | jules@lens <julescarbon@gmail.com> | 2019-04-02 20:36:51 +0200 |
|---|---|---|
| committer | jules@lens <julescarbon@gmail.com> | 2019-04-02 20:36:51 +0200 |
| commit | 1d238346b5609e9454a4917c75631a550b5b43d1 (patch) | |
| tree | 8a936e721e78c7b5948b303e6a1686c96b882d51 /scraper/client/paper/paper.verify.js | |
| parent | b4b58f2279fb01fa0240006c460c0b5ec95c1126 (diff) | |
| parent | f58d41731fc07d94d594d5582aef203564f990ec (diff) | |
Merge branch 'master' of asdf.us:megapixels_dev
Diffstat (limited to 'scraper/client/paper/paper.verify.js')
| -rw-r--r-- | scraper/client/paper/paper.verify.js | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/scraper/client/paper/paper.verify.js b/scraper/client/paper/paper.verify.js index 83eb5b44..813abb6d 100644 --- a/scraper/client/paper/paper.verify.js +++ b/scraper/client/paper/paper.verify.js @@ -36,7 +36,9 @@ class PaperVerify extends Component { const { sha256 } = this.props.match.params this.props.actions.getInstitutions() this.props.actions.getAddress(sha256) - this.props.actions.getVerification(sha256) + if (this.props.api.paperInfo.dataset) { + this.props.actions.getVerification(this.props.api.paperInfo.dataset.key, sha256) + } const citationState = this.getCitationState(sha256) // console.log('DID MOUNT') this.setState(citationState) @@ -51,15 +53,20 @@ class PaperVerify extends Component { const paper = verify ? verify.paper : null let newState = {} + if (this.props.api.paperInfo.dataset !== oldProps.api.paperInfo.dataset) { + this.props.actions.getVerification(this.props.api.paperInfo.dataset.key, sha256) + } + if (oldSha256 && sha256 !== oldSha256) { - console.log('update verification') + // console.log('update verification') this.props.actions.getAddress(sha256) - this.props.actions.getVerification(sha256) + this.props.actions.getVerification(this.props.api.paperInfo.dataset.key, sha256) const citationState = this.getCitationState(sha256) newState = { ...initialState, ...citationState, ...address.paper, + pdfIndex: citationState.citation.pdf.findIndex(el => el.match(/^https:/)), } this.setState(newState) } else if (verify && !verify.loading && verify.paper && (!oldPaper || oldPaper !== verify.paper)) { @@ -70,6 +77,7 @@ class PaperVerify extends Component { ...initialState, ...citationState, ...address.paper, + pdfIndex: citationState.citation.pdf.findIndex(el => el.match(/^https:/)), } this.setState(newState) } else { @@ -79,6 +87,7 @@ class PaperVerify extends Component { newState = { ...citationState, ...address.paper, + pdfIndex: citationState.citation.pdf.findIndex(el => el.match(/^https:/)), uses_dataset: paper.uses_dataset, images_in_paper: paper.images_in_paper, verified_by: paper.verified_by, @@ -156,7 +165,7 @@ class PaperVerify extends Component { if (citationIndex < 0) { history.push('/paper/' + key + '/info/') } else { - let nextId = citations[citationIndex].id + let nextId = sortedCitations[citationIndex].id history.push('/paper/' + key + '/verify/' + nextId) } } @@ -167,15 +176,16 @@ class PaperVerify extends Component { const { paperInfo, sortedCitations } = this.props.api const citations = sortedCitations || paperInfo.citations || [] let citationIndex = citations.findIndex(f => f.id === this.state.citation.id) - + console.log(sortedCitations) + console.log('going to next', key, citationIndex) if (citationIndex === -1) { history.push('/paper/' + key + '/info/') } else { citationIndex += 1 - if (citationIndex >= citations.length) { + if (citationIndex >= sortedCitations.length) { history.push('/paper/' + key + '/info/') } else { - let nextId = citations[citationIndex].id + let nextId = sortedCitations[citationIndex].id history.push('/paper/' + key + '/verify/' + nextId) } } @@ -414,7 +424,10 @@ class PaperVerify extends Component { >{'Next >'}</button> </div> - <iframe className='pdfViewer' referrerPolicy='no-referrer' src={citation.pdf[this.state.pdf_index]} /> + {citation.pdf.length + ? <iframe className='pdfViewer' referrerPolicy='no-referrer' src={citation.pdf[this.state.pdf_index] || "about:blank"} /> + : '' + } </div> ) } |
