diff options
| author | adamhrv <adam@ahprojects.com> | 2019-03-28 20:01:11 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2019-03-28 20:01:11 +0100 |
| commit | 21fd4284ac0f14ec860ccda1032ef380ccfa7b2f (patch) | |
| tree | 6751b86621a1ad76ebab1ffe9f0d1a6ab053bacc /scraper/client | |
| parent | b2c61d7ebc142b41f8cb15b00764319801d1bf5d (diff) | |
| parent | 5309b381e64f59b8f57014ad41e55d7f87ca0628 (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'scraper/client')
| -rw-r--r-- | scraper/client/actions.js | 9 | ||||
| -rw-r--r-- | scraper/client/common/autocomplete.component.js | 49 | ||||
| -rw-r--r-- | scraper/client/paper/citationList.component.js | 111 | ||||
| -rw-r--r-- | scraper/client/paper/paper.citations.js | 86 | ||||
| -rw-r--r-- | scraper/client/paper/paper.css | 9 | ||||
| -rw-r--r-- | scraper/client/paper/paper.info.js | 4 | ||||
| -rw-r--r-- | scraper/client/paper/paper.unknown.js | 48 | ||||
| -rw-r--r-- | scraper/client/paper/paper.verify.js | 142 | ||||
| -rw-r--r-- | scraper/client/store.js | 10 | ||||
| -rw-r--r-- | scraper/client/types.js | 5 |
10 files changed, 320 insertions, 153 deletions
diff --git a/scraper/client/actions.js b/scraper/client/actions.js index 734a8cbd..b5c477f6 100644 --- a/scraper/client/actions.js +++ b/scraper/client/actions.js @@ -1,9 +1,10 @@ import { get, post } from './util' import * as types from './types' -export const api = (dispatch, method, tag, url, params) => { +export const api = (dispatch, method, tag, url, params, after) => { dispatch({ type: types.api.loading, tag }) return method(url, params).then(data => { + if (after) data = after(data) dispatch({ type: types.api.loaded, tag, data }) return data }).catch(err => { @@ -36,6 +37,10 @@ export const getVerifications = () => dispatch => ( api(dispatch, get, 'verifications', '/api/verifications', {}) ) +export const getVerificationsDataset = dataset => dispatch => ( + api(dispatch, get, 'verifications', '/api/verifications/' + dataset, {}) +) + export const getVerification = sha256 => dispatch => ( api(dispatch, get, 'verify', '/api/verify/' + sha256, {}) ) @@ -44,5 +49,5 @@ export const postVerification = data => dispatch => ( api(dispatch, post, 'verify', '/api/verify/add', data) ) - +export const setSortedCitations = sortedCitations => dispatch => dispatch({ type: types.system.set_sorted_citations, sortedCitations }) diff --git a/scraper/client/common/autocomplete.component.js b/scraper/client/common/autocomplete.component.js index e2908cd1..67dc78c9 100644 --- a/scraper/client/common/autocomplete.component.js +++ b/scraper/client/common/autocomplete.component.js @@ -49,6 +49,10 @@ class Autocomplete extends Component { componentDidMount() { // build index based on what's in the hierarchy + if (!this.props.institutions.loading) this.buildIndex() + } + + buildIndex() { const { entities, lookup } = this.props.institutions let index = [] this.index = index @@ -69,6 +73,9 @@ class Autocomplete extends Component { } componentDidUpdate(oldProps) { + if (oldProps.institutions.loading && !this.props.institutions.loading) { + this.buildIndex() + } if (this.props.vetting !== oldProps.vetting) { this.handleChange({ target: { value: this.props.vetting } }) } else if (this.props.value !== oldProps.value) { @@ -77,30 +84,37 @@ class Autocomplete extends Component { } handleKeyDown(e) { - let id + let name + console.log(e.keyCode) switch (e.keyCode) { case 27: // escape e.preventDefault() this.handleCancel() break - case 37: // left case 38: // up e.preventDefault() this.setState({ selected: (this.state.matches.length + this.state.selected - 1) % this.state.matches.length }) return false - case 39: // right case 40: // down e.preventDefault() this.setState({ selected: (this.state.selected + 1) % this.state.matches.length }) return false - case 13: // enter - id = this.state.matches[this.state.selected] + case 13: // enter - select from the list + name = this.state.matches[this.state.selected] e.preventDefault() - this.handleSelect(id) + this.handleSelect(name, true) + return false + case 9: // tab - keep the unverified text + name = this.state.matches[this.state.selected] + if (name === this.state.q) { + this.handleSelect(this.state.q, true) + } else { + this.handleSelect(this.state.q, false) + } return false default: break @@ -121,7 +135,6 @@ class Autocomplete extends Component { return } let seen = {} - let matches = [] value.split(' ').forEach(word => { const re = new RegExp(word) this.index.forEach(([synonym, term]) => { @@ -139,14 +152,14 @@ class Autocomplete extends Component { } } }) - matches = Object.keys(seen) - .map(term => [seen[term], term]) - .sort((a, b) => { - return b[0] - a[0] - }) - .slice(0, 100) - .map(pair => pair[1]) }) + let matches = Object.keys(seen) + .map(term => [seen[term], term]) + .sort((a, b) => { + return b[0] - a[0] + }) + .slice(0, 100) + .map(pair => pair[1]) this.setState({ q, selected: 0, @@ -154,9 +167,9 @@ class Autocomplete extends Component { }) } - handleSelect(name) { - console.log('select', name) - if (this.props.onSelect) this.props.onSelect(name) + handleSelect(name, valid) { + console.log('select', name, valid) + if (this.props.onSelect) this.props.onSelect(name, valid) this.setState({ q: name, selected: 0, matches: [] }) } @@ -173,7 +186,7 @@ class Autocomplete extends Component { <div key={i} className={selected === i ? 'selected' : ''} - onClick={() => this.handleSelect(match)} + onClick={() => this.handleSelect(match, true)} onMouseEnter={() => this.setState({ selected: i })} > {label} diff --git a/scraper/client/paper/citationList.component.js b/scraper/client/paper/citationList.component.js new file mode 100644 index 00000000..10e3ba9a --- /dev/null +++ b/scraper/client/paper/citationList.component.js @@ -0,0 +1,111 @@ +import React, { Component } from 'react' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' + +import * as actions from '../actions' + +import { TableObject, Loader } from '../common' +import { USES_DATASET } from '../types' + +class CitationList extends Component { + componentDidMount() { + const { citations, api } = this.props + const { paperInfo, unknownCitations, verifications } = api + const { dataset } = paperInfo + if (!dataset || !citations || !verifications[dataset.key]) { + this.props.actions.setSortedCitations([]) + return + } + let verifiedLookup = verifications[dataset.key] || {} + const sortedCitations = citations.map(citation => [ + citation.title, + verifiedLookup[citation.id] ? verifiedLookup[citation.id].uses_dataset : USES_DATASET.NO_DATA, + citation.pdf.length, + citation + ]) + .sort((a,b) => (b[1] - a[1] || b[2] - a[2] || (a[0].localeCompare(b[0])))) + .map(tup => tup[3]) + this.props.actions.setSortedCitations(sortedCitations) + } + + render() { + const { citations, title, api } = this.props + const { paperInfo, unknownCitations, verifications, sortedCitations } = api + const { dataset } = paperInfo + if (!dataset || !citations || !verifications[dataset.key]) return <Loader /> + let verifiedLookup = verifications[dataset.key] || {} + // console.log(verifications) + return ( + <div className='citations'> + <h2>{title}</h2> + <ul> + {(sortedCitations || []).map((citation, i) => { + let cite = { ...citation } + cite.id = { + _raw: true, + value: <Link to={'/paper/' + dataset.key + '/verify/' + citation.id}>{citation.id}</Link> + } + cite.pdf = { + _raw: true, + value: (cite.pdf && cite.pdf.length) + ? cite.pdf.map((pdf, i) => <a key={'pdf_' + i} href={pdf} rel='noopener noreferrer' target="_blank">[pdf]</a>) + : "no pdf" + } + cite.s2 = { + _raw: true, + value: <a + href={'https://www.semanticscholar.org/paper/' + citation.id} + target="_blank" + rel="noopener noreferrer" + className={'pdfLink'} + >{'[semantic scholar]'}</a> + } + cite.addresses = { + _raw: true, + value: (cite.addresses || []).map((address, j) => ( + <div key={j}>{address.name}{', '}<span className='type'>{address.type}</span></div> + )) + } + if (citation.id in verifiedLookup) { + const verification = verifiedLookup[citation.id] + cite.verified = { + _raw: true, + value: verification.uses_dataset === USES_DATASET.YES + ? <span className='verified'>uses dataset</span> + : verification.uses_dataset === USES_DATASET.NO + ? <span className='unverified'>{"doesn't use dataset"}</span> + : <span className='not_enough_info'>{"not enough information"}</span> + } + } + else { + cite.verified = { + _raw: true, + value: <span className='unknown'>unknown</span> + } + } + return ( + <li key={i}> + <TableObject + summary + object={cite} + tag={cite.title} + order={['id', 'pdf', 's2', 'year', 'addresses', 'verified']} + /> + </li> + ) + })} + </ul> + </div> + ) + } +} + +const mapStateToProps = state => ({ + api: state.api, +}) +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ ...actions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(CitationList) diff --git a/scraper/client/paper/paper.citations.js b/scraper/client/paper/paper.citations.js index 5c8e0e0c..f0e9ea26 100644 --- a/scraper/client/paper/paper.citations.js +++ b/scraper/client/paper/paper.citations.js @@ -5,84 +5,28 @@ import { Link } from 'react-router-dom' import * as actions from '../actions' -import { TableObject } from '../common' +import { Loader } from '../common' import { USES_DATASET } from '../types' +import CitationList from './citationList.component' + class PaperCitations extends Component { - componentDidMount() { - this.props.actions.getVerifications() + componentDidUpdate(prevProps) { + if (this.props.api.paperInfo.dataset !== prevProps.api.paperInfo.dataset) { + this.props.actions.getVerificationsDataset(this.props.api.paperInfo.dataset.key) + } } render() { - const { dataset, citations } = this.props.api.paperInfo - let { verifications } = this.props.api.verifications - verifications = verifications || {} - if (!dataset || !citations) return null - console.log('rendering citations...') - // console.log(citations) + const { paperInfo, unknownCitations, verifications } = this.props.api + const { dataset, citations } = paperInfo + if (!dataset || !citations || !verifications[dataset.key]) return <Loader /> + return ( - <div className='citations'> - <h2>{dataset.name_full}: Citations</h2> - <ul> - {citations.map((citation, i) => { - let cite = { ...citation } - cite.id = { - _raw: true, - value: <Link to={'/paper/' + dataset.key + '/verify/' + citation.id}>{citation.id}</Link> - } - cite.pdf = { - _raw: true, - value: (cite.pdf && cite.pdf.length) ? <a href={cite.pdf[0]} rel='noopener noreferrer' target="_blank">[pdf]</a> : "no pdf" - } - cite.s2 = { - _raw: true, - value: <a - href={'https://www.semanticscholar.org/paper/' + citation.id} - target="_blank" - rel="noopener noreferrer" - className={'pdfLink'} - >{'[semantic scholar]'}</a> - } - cite.addresses = { - _raw: true, - value: cite.addresses.map((address, j) => ( - <div key={j}>{address.name}{', '}<span className='type'>{address.type}</span></div> - )) - } - if (citation.id in verifications && verifications[citation.id].dataset === dataset.key) { - const verification = verifications[citation.id] - cite.verified = { - _raw: true, - value: verification.uses_dataset === USES_DATASET.YES - ? <span className='verified'>uses dataset</span> - : verification.uses_dataset === USES_DATASET.NO - ? <span className='unverified'>{"doesn't use dataset"}</span> - : verification.uses_dataset === 'TRUE' - ? <span className='verified'>uses dataset</span> - : verification.uses_dataset === 'FALSE' - ? <span className='unverified'>{"doesn't use dataset"}</span> - : <span className='unknown'>{"not enough information"}</span> - } - } - else { - cite.verified = { - _raw: true, - value: <span className='unknown'>unknown</span> - } - } - return ( - <li key={i}> - <TableObject - summary - object={cite} - tag={cite.title} - order={['id', 'pdf', 's2', 'year', 'addresses', 'verified']} - /> - </li> - ) - })} - </ul> - </div> + <CitationList + title={dataset.name_full + ': Citations'} + citations={citations.concat(unknownCitations.citations)} + /> ) } } diff --git a/scraper/client/paper/paper.css b/scraper/client/paper/paper.css index ac711559..9bb684ff 100644 --- a/scraper/client/paper/paper.css +++ b/scraper/client/paper/paper.css @@ -62,6 +62,15 @@ padding:4px; font-size:12px; } +.not_enough_info { + font-weight: bold; + color: white; + font-weight: bold; + display: inline-block; + background: #e0c200; + padding:4px; + font-size:12px; +} .unknown { font-weight: bold; color: white; diff --git a/scraper/client/paper/paper.info.js b/scraper/client/paper/paper.info.js index a8553c9b..35234617 100644 --- a/scraper/client/paper/paper.info.js +++ b/scraper/client/paper/paper.info.js @@ -9,7 +9,7 @@ import { TableObject } from '../common' class PaperInfo extends Component { render() { const { paperInfo, unknownCitations } = this.props.api - const { dataset, statistics, address } = paperInfo + const { dataset, address } = paperInfo if (!dataset) return null return ( <div className='paperInfo'> @@ -21,7 +21,7 @@ class PaperInfo extends Component { /> <TableObject summary tag="Statistics" - object={statistics} + object={dataset} order={['year_published', 'purpose_short', 'wild', 'indoor', 'outdoor', 'cyberspace', 'names', 'downloaded', diff --git a/scraper/client/paper/paper.unknown.js b/scraper/client/paper/paper.unknown.js index 0cb7d2da..876ac144 100644 --- a/scraper/client/paper/paper.unknown.js +++ b/scraper/client/paper/paper.unknown.js @@ -5,40 +5,28 @@ import { Link } from 'react-router-dom' import * as actions from '../actions' -import { TableObject } from '../common' +import { Loader } from '../common' +import { USES_DATASET } from '../types' + +import CitationList from './citationList.component' class PaperUnknown extends Component { + componentDidUpdate(prevProps) { + if (this.props.api.paperInfo.dataset !== prevProps.api.paperInfo.dataset) { + this.props.actions.getVerificationsDataset(this.props.api.paperInfo.dataset.key) + } + } + render() { - const { dataset } = this.props.api.paperInfo - const { citations } = this.props.api.unknownCitations - if (!dataset || !citations) return null - console.log('rendering unknown citations...') + const { paperInfo, unknownCitations, verifications } = this.props.api + const { dataset, citations } = paperInfo + if (!dataset || !citations || !verifications[dataset.key]) return <Loader /> + return ( - <div className='citations'> - <h2>{dataset.name_full}: Unknown Citations</h2> - <ul> - {citations.map((citation, i) => { - let cite = { ...citation } - cite.id = { - _raw: true, - value: <Link to={'/paper/' + dataset.key + '/address/' + citation.id}>{citation.id}</Link> - } - cite.pdf = { - _raw: true, - value: cite.pdf ? <a href={cite.pdf} rel='noopener noreferrer' target="_blank">[pdf]</a> : "no pdf" - } - return ( - <li key={i}> - <TableObject - summary - object={cite} - tag={cite.title} - /> - </li> - ) - })} - </ul> - </div> + <CitationList + title={dataset.name_full + ': Unknown Citations'} + citations={unknownCitations.citations} + /> ) } } diff --git a/scraper/client/paper/paper.verify.js b/scraper/client/paper/paper.verify.js index 65342adf..f5dbc13c 100644 --- a/scraper/client/paper/paper.verify.js +++ b/scraper/client/paper/paper.verify.js @@ -4,18 +4,27 @@ import { connect } from 'react-redux' import * as actions from '../actions' import { history } from '../store' -import { Loader } from '../common' +import { Loader, Autocomplete } from '../common' import { USES_DATASET } from '../types' const initialState = { citation: null, + address: {}, uses_dataset: USES_DATASET.UNKNOWN, images_in_paper: "FALSE", used_as_model: "FALSE", verified_by: localStorage.getItem('verify.username') || '', reference: '', notes: '', + location: '', pdf_index: 0, + isUnknown: false, + institution_1: '', + institution_2: '', + institution_3: '', + validate_1: false, + validate_2: false, + validate_3: false, } class PaperVerify extends Component { @@ -26,6 +35,7 @@ class PaperVerify extends Component { componentDidMount() { const { sha256 } = this.props.match.params this.props.actions.getInstitutions() + this.props.actions.getAddress(sha256) this.props.actions.getVerification(sha256) const citationState = this.getCitationState(sha256) console.log('DID MOUNT') @@ -34,52 +44,67 @@ class PaperVerify extends Component { componentDidUpdate(oldProps) { const { sha256 } = this.props.match.params - const { verify } = this.props.api + const { address, verify } = this.props.api const { sha256: oldSha256 } = oldProps.match.params - const { verify: oldVerify } = oldProps.api + const { verify: oldVerify, address: oldAddress } = oldProps.api const oldPaper = oldVerify ? oldVerify.paper : null const paper = verify ? verify.paper : null + let newState = {} if (oldSha256 && sha256 !== oldSha256) { console.log('update verification') + this.props.actions.getAddress(sha256) this.props.actions.getVerification(sha256) const citationState = this.getCitationState(sha256) - this.setState({ + newState = { ...initialState, ...citationState, - }) + ...address.paper, + } + this.setState(newState) } else if (verify && !verify.loading && verify.paper && (!oldPaper || oldPaper !== verify.paper)) { if (paper.error) { console.log('USING PAPER VERIFICATION') const citationState = this.getCitationState(sha256) - this.setState({ + newState = { ...initialState, ...citationState, - }) + ...address.paper, + } + this.setState(newState) } else { // console.log(paper) console.log('GOT CUSTOM CITATION STATE', paper) const citationState = this.getCitationState(sha256) - this.setState({ + newState = { ...citationState, - uses_dataset: paper.uses_dataset === "TRUE", - images_in_paper: paper.images_in_paper === "TRUE", + ...address.paper, + uses_dataset: paper.uses_dataset, + images_in_paper: paper.images_in_paper, verified_by: paper.verified_by, reference: paper.reference, notes: paper.notes, - }) + } + this.setState(newState) } } else if (oldProps.api.unknownCitations !== this.props.api.unknownCitations) { + console.log('loaded unknown citations') const citationState = this.getCitationState(sha256) - this.setState(citationState) + newState = citationState + this.setState(newState) } } getCitationState(sha256) { const { paperInfo, unknownCitations } = this.props.api let citation = (unknownCitations.citations || []).find(f => f.id === sha256) - if (!citation) { + if (citation) { + citation.isUnknown = true + } else { citation = (paperInfo.citations || []).find(f => f.id === sha256) + if (citation) { + citation.isUnknown = false + } } // console.log(sha256, citation) let state = { citation } @@ -107,15 +132,23 @@ class PaperVerify extends Component { reference: this.state.reference, notes: this.state.notes, date: dateString, + isUnknown: this.state.citation.isUnknown, + institution_1: this.state.institution_1, + validate_1: this.state.validate_1, + institution_2: this.state.institution_2, + validate_2: this.state.validate_2, + institution_3: this.state.institution_3, + validate_3: this.state.validate_3, }) - this.next(false) + this.next() } prev() { const { key } = this.props.api.paperInfo.dataset - const { paperInfo } = this.props.api - let citationIndex = (paperInfo.citations || []) - .findIndex(f => f.id === this.state.citation.id) + const { paperInfo, sortedCitations } = this.props.api + const citations = sortedCitations || paperInfo.citations || [] + let citationIndex = citations.findIndex(f => f.id === this.state.citation.id) + if (citationIndex === -1) { history.push('/paper/' + key + '/info/') } else { @@ -123,7 +156,7 @@ class PaperVerify extends Component { if (citationIndex < 0) { history.push('/paper/' + key + '/info/') } else { - let nextId = paperInfo.citations[citationIndex].id + let nextId = citations[citationIndex].id history.push('/paper/' + key + '/verify/' + nextId) } } @@ -131,24 +164,25 @@ class PaperVerify extends Component { next() { const { key } = this.props.api.paperInfo.dataset - const { paperInfo } = this.props.api - let citationIndex = (paperInfo.citations || []) - .findIndex(f => f.id === this.state.citation.id) + const { paperInfo, sortedCitations } = this.props.api + const citations = sortedCitations || paperInfo.citations || [] + let citationIndex = citations.findIndex(f => f.id === this.state.citation.id) + if (citationIndex === -1) { history.push('/paper/' + key + '/info/') } else { citationIndex += 1 - if (citationIndex >= paperInfo.citations.length) { + if (citationIndex >= citations.length) { history.push('/paper/' + key + '/info/') } else { - let nextId = paperInfo.citations[citationIndex].id + let nextId = citations[citationIndex].id history.push('/paper/' + key + '/verify/' + nextId) } } } render() { - let { paperInfo } = this.props.api + const { paperInfo, unknownCitations } = this.props.api if (paperInfo.loading) return <Loader /> // console.log(this.state) const { citation } = this.state @@ -185,6 +219,8 @@ class PaperVerify extends Component { </a> </div> + {this.renderLocationForm()} + <div className='row vettingRow'> <div className='rowHeading'> {'Uses dataset'} @@ -194,7 +230,7 @@ class PaperVerify extends Component { className='vetting' type='radio' name='uses_dataset' - checked={this.state.uses_dataset === USES_DATASET.YES || this.state.uses_dataset === "FALSE"} + checked={String(this.state.uses_dataset) === USES_DATASET.YES} onChange={e => this.setState({ uses_dataset: USES_DATASET.YES, })} @@ -207,7 +243,7 @@ class PaperVerify extends Component { className='vetting' type='radio' name='uses_dataset' - checked={this.state.uses_dataset === USES_DATASET.NO || this.state.uses_dataset === "FALSE"} + checked={String(this.state.uses_dataset) === USES_DATASET.NO} onChange={e => this.setState({ uses_dataset: USES_DATASET.NO, })} @@ -220,7 +256,7 @@ class PaperVerify extends Component { className='vetting' type='radio' name='uses_dataset' - checked={this.state.uses_dataset === USES_DATASET.UNKNOWN || this.state.uses_dataset === "FALSE"} + checked={String(this.state.uses_dataset) !== USES_DATASET.YES && String(this.state.uses_dataset) !== USES_DATASET.NO} onChange={e => this.setState({ uses_dataset: USES_DATASET.UNKNOWN, })} @@ -230,8 +266,8 @@ class PaperVerify extends Component { </div> <div - className={this.state.uses_dataset === USES_DATASET.YES ? 'row vettingRow' : 'row vettingRow disabled'} - disabled={this.state.uses_dataset === USES_DATASET.YES ? false : true} + className={String(this.state.uses_dataset) === USES_DATASET.YES ? 'row vettingRow' : 'row vettingRow disabled'} + disabled={String(this.state.uses_dataset) === USES_DATASET.YES ? false : true} > <div className='rowHeading'> {'Paper shows images'} @@ -355,6 +391,54 @@ class PaperVerify extends Component { </div> ) } + renderLocationForm() { + if (!this.state.citation.isUnknown) return + return ( + <div> + <div className='param'> + <label>Institution #1</label> + <Autocomplete + placeholder='Institution #1' + value={this.state.institution_1} + onSelect={(institution_1, validate_1) => { + this.setState({ institution_1, validate_1 }) + }} + onCancel={value => { + this.setState({ institution_1: '', validate_1: false }) + }} + /> + </div> + + <div className='param'> + <label>Institution #2</label> + <Autocomplete + placeholder='Institution #2' + value={this.state.institution_2} + onSelect={(institution_2, validate_2) => { + this.setState({ institution_2, validate_2 }) + }} + onCancel={value => { + this.setState({ institution_2: '', validate_2: false }) + }} + /> + </div> + + <div className='param'> + <label>Institution #3</label> + <Autocomplete + placeholder='Institution #3' + value={this.state.institution_3} + onSelect={(institution_3, validate_3) => { + this.setState({ institution_3, validate_3 }) + }} + onCancel={value => { + this.setState({ institution_3: '', validate_3: false }) + }} + /> + </div> + </div> + ) + } } /* diff --git a/scraper/client/store.js b/scraper/client/store.js index b199ae29..6da60cbe 100644 --- a/scraper/client/store.js +++ b/scraper/client/store.js @@ -15,7 +15,8 @@ const initialState = () => ({ unknownCitations: {}, verify: {}, verifications: {}, - options: {} + options: {}, + sortedCitations: [], }) export default function apiReducer(state = initialState(), action) { @@ -45,6 +46,13 @@ export default function apiReducer(state = initialState(), action) { paperKey: action.paperKey } + case types.system.set_sorted_citations: + console.log(action.sortedCitations || []) + return { + ...state, + sortedCitations: action.sortedCitations || [], + } + default: return state } diff --git a/scraper/client/types.js b/scraper/client/types.js index 95b7a4e3..22c93a89 100644 --- a/scraper/client/types.js +++ b/scraper/client/types.js @@ -10,10 +10,15 @@ export const api = tagAsType('api', [ 'loading', 'loaded', 'error', 'set_paper_key', ]) +export const system = tagAsType('system', [ + 'set_sorted_citations', +]) + export const init = '@@INIT' export const USES_DATASET = { YES: "1", NO: "-1", UNKNOWN: "0", + NO_DATA: "-2", } |
