mirror of
https://github.com/mue/mue.git
synced 2026-07-09 21:45:26 +02:00
fix: add some catches to stats just in case
This commit is contained in:
@@ -28,7 +28,7 @@ export default class Stats {
|
||||
static async postEvent(type, name) {
|
||||
const value = name.toLowerCase().replaceAll(' ', '-');
|
||||
|
||||
const data = JSON.parse(localStorage.getItem('statsData'));
|
||||
const data = JSON.parse(localStorage.getItem('statsData')) || {};
|
||||
// tl;dr this creates the objects if they don't exist
|
||||
// this really needs a cleanup at some point
|
||||
if (!data[type] || !data[type][value]) {
|
||||
@@ -50,7 +50,7 @@ export default class Stats {
|
||||
* It increments the value of the key 'tabs-opened' in the object stored in localStorage by 1.
|
||||
*/
|
||||
static async tabLoad() {
|
||||
const data = JSON.parse(localStorage.getItem('statsData'));
|
||||
const data = JSON.parse(localStorage.getItem('statsData')) || {};
|
||||
data['tabs-opened'] = data['tabs-opened'] + 1 || 1;
|
||||
localStorage.setItem('statsData', JSON.stringify(data));
|
||||
this.achievementTrigger(data);
|
||||
|
||||
Reference in New Issue
Block a user