mirror of
https://github.com/mue/mue.git
synced 2026-07-22 00:07:23 +02:00
feat: add work in progress 7.0 code
Co-authored-by: Alex Sparkes <turbomarshmello@gmail.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import variables from 'modules/variables';
|
||||
import { PureComponent } from 'react';
|
||||
import { MdShowChart } from 'react-icons/md';
|
||||
|
||||
import Switch from '../Switch';
|
||||
import SettingsItem from '../SettingsItem';
|
||||
|
||||
import EventBus from 'modules/helpers/eventbus';
|
||||
|
||||
@@ -9,17 +11,17 @@ export default class Stats extends PureComponent {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
stats: JSON.parse(localStorage.getItem('statsData')) || {}
|
||||
stats: JSON.parse(localStorage.getItem('statsData')) || {},
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
EventBus.on('refresh', (data) => {
|
||||
componentDidMount() {
|
||||
EventBus.on('refresh', (data) => {
|
||||
if (data === 'stats') {
|
||||
if (localStorage.getItem('stats') === 'false') {
|
||||
localStorage.setItem('statsData', JSON.stringify({}));
|
||||
return this.setState({
|
||||
stats: {}
|
||||
stats: {},
|
||||
});
|
||||
}
|
||||
this.forceUpdate();
|
||||
@@ -37,24 +39,95 @@ export default class Stats extends PureComponent {
|
||||
if (localStorage.getItem('stats') === 'false') {
|
||||
return (
|
||||
<>
|
||||
<h2>{getMessage('modals.main.settings.reminder.title')}</h2>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.warning')}</p>
|
||||
<Switch name='stats' text={getMessage('modals.main.settings.sections.stats.usage')} category='stats'/>
|
||||
<span className="mainTitle">
|
||||
{getMessage('modals.main.settings.sections.stats.title')}
|
||||
</span>
|
||||
<SettingsItem
|
||||
title={getMessage('modals.main.settings.reminder.title')}
|
||||
subtitle={getMessage('modals.main.settings.sections.stats.warning')}
|
||||
>
|
||||
<Switch
|
||||
name="stats"
|
||||
text={getMessage('modals.main.settings.sections.stats.usage')}
|
||||
category="stats"
|
||||
/>
|
||||
</SettingsItem>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2>{getMessage('modals.main.settings.sections.stats.title')}</h2>
|
||||
<Switch name='stats' text={getMessage('modals.main.settings.sections.stats.usage')} category='stats'/>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.tabs_opened')}: {this.state.stats['tabs-opened'] || 0}</p>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.backgrounds_favourited')}: {this.state.stats.feature ? this.state.stats.feature['background-favourite'] || 0 : 0}</p>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.backgrounds_downloaded')}: {this.state.stats.feature ? this.state.stats.feature['background-download'] || 0 : 0}</p>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.quotes_favourited')}: {this.state.stats.feature ? this.state.stats.feature['quoted-favourite'] || 0 : 0}</p>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.quicklinks_added')}: {this.state.stats.feature ? this.state.stats.feature['quicklink-add'] || 0 : 0}</p>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.settings_changed')}: {this.state.stats.setting ? Object.keys(this.state.stats.setting).length : 0}</p>
|
||||
<p>{getMessage('modals.main.settings.sections.stats.sections.addons_installed')}: {this.state.stats.marketplace ? this.state.stats.marketplace['install'] : 0}</p>
|
||||
{/*<h2>{getMessage('modals.main.settings.sections.stats.title')}</h2>
|
||||
<Switch name='stats' text={getMessage('modals.main.settings.sections.stats.usage')} category='stats'/>*/}
|
||||
<span className="mainTitle">{getMessage('modals.main.settings.sections.stats.title')}</span>
|
||||
<SettingsItem
|
||||
title={getMessage('modals.main.settings.reminder.title')}
|
||||
subtitle={getMessage('modals.main.settings.sections.stats.warning')}
|
||||
>
|
||||
<Switch
|
||||
name="stats"
|
||||
text={getMessage('modals.main.settings.sections.stats.usage')}
|
||||
category="stats"
|
||||
/>
|
||||
</SettingsItem>
|
||||
<div className="statsGrid">
|
||||
<div>
|
||||
<span>
|
||||
{getMessage('modals.main.settings.sections.stats.sections.tabs_opened')}:{' '}
|
||||
{this.state.stats['tabs-opened'] || 0}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>
|
||||
{getMessage('modals.main.settings.sections.stats.sections.tabs_opened')}:{' '}
|
||||
{this.state.stats['tabs-opened'] || 0}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<MdShowChart />
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.tabs_opened')}{' '}
|
||||
</span>
|
||||
<span>{this.state.stats['tabs-opened'] || 0}</span>
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.backgrounds_favourited')}{' '}
|
||||
</span>
|
||||
<span>
|
||||
{this.state.stats.feature ? this.state.stats.feature['background-favourite'] || 0 : 0}
|
||||
</span>
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.backgrounds_downloaded')}{' '}
|
||||
</span>
|
||||
<span>
|
||||
{this.state.stats.feature ? this.state.stats.feature['background-download'] || 0 : 0}
|
||||
</span>
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.quotes_favourited')}{' '}
|
||||
</span>
|
||||
<span>
|
||||
{this.state.stats.feature ? this.state.stats.feature['quoted-favourite'] || 0 : 0}
|
||||
</span>
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.quicklinks_added')}{' '}
|
||||
</span>
|
||||
<span>
|
||||
{this.state.stats.feature ? this.state.stats.feature['quicklink-add'] || 0 : 0}
|
||||
</span>
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.settings_changed')}{' '}
|
||||
</span>
|
||||
<span>
|
||||
{this.state.stats.setting ? Object.keys(this.state.stats.setting).length : 0}
|
||||
</span>
|
||||
<span className="subtitle">
|
||||
{getMessage('modals.main.settings.sections.stats.sections.addons_installed')}{' '}
|
||||
</span>
|
||||
<span>
|
||||
{this.state.stats.marketplace ? this.state.stats.marketplace['install'] : 0}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user