import React, {PureComponent} from 'react'; import autobind from 'autobind-decorator'; import Link from '../base/Link'; import Modal from '../base/Modal'; import ModalBody from '../base/ModalBody'; import ModalHeader from '../base/ModalHeader'; import ModalFooter from '../base/ModalFooter'; import {getAppVersion, CHANGELOG_URL, CHANGELOG_PAGE} from '../../../common/constants'; @autobind class ChangelogModal extends PureComponent { constructor (props) { super(props); this.state = { changelog: null }; } _setModalRef (m) { this.modal = m; } show () { this.modal.show(); } toggle () { this.modal.toggle(); } async componentDidMount () { let changelog; try { const response = await window.fetch(`${CHANGELOG_URL}?bust=${Date.now()}`); changelog = await response.json(); } catch (e) { console.warn('Failed to fetch changelog', e); return; } this.setState({changelog}); } render () { const {changelog} = this.state; let html; if (!changelog) { html = [
{change.summary}
]; } else { html = [ ...html,{change.summary[0]}
, ...change.summary.slice(1).map( (text, j) =>{text}
) ]; } } if (change.link) { html = [ ...html, Read More ]; } if (change.major && change.major.length) { html = [ ...html,