mirror of
https://github.com/mue/mue.git
synced 2026-07-03 13:13:14 +02:00
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
|
|
export default class Update extends React.Component {
|
|
constructor(...args) {
|
|
super(...args);
|
|
this.state = {
|
|
title: 'Loading...',
|
|
date: '',
|
|
content: 'Loading...'
|
|
};
|
|
}
|
|
|
|
async getUpdate() {
|
|
const enabled = localStorage.getItem('offlineMode');
|
|
if (enabled === 'true') return this.setState({
|
|
title: 'Offline',
|
|
content: 'Cannot get update logs while in offline mode'
|
|
});
|
|
|
|
try { // First we try and get a quote from the API...
|
|
let data = await fetch('https://api.muetab.xyz/getUpdate');
|
|
data = await data.json();
|
|
this.setState({
|
|
title: data.title,
|
|
content: data.content
|
|
});
|
|
} catch (e) {
|
|
this.setState({
|
|
title: 'Error',
|
|
content: 'Could not connect to the server!'
|
|
});
|
|
}
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.getUpdate();
|
|
}
|
|
|
|
render() {
|
|
return <div className="content">
|
|
<span className="closeModal" onClick={this.props.modalClose}>×</span>
|
|
<h1 dangerouslySetInnerHTML={{__html: this.state.title}}></h1>
|
|
<p dangerouslySetInnerHTML={{__html: this.state.content}}></p>
|
|
</div>;
|
|
}
|
|
} |