<commit_before>import { assign } from 'lodash';

import http from '../services/http';
import userStore from './user';
import preferenceStore from './preference';
import artistStore from './artist';
import songStore from './song';
import playlistStore from './playlist';
import queueStore from './queue';
import settingStore from './setting';

export default {
    state: {
        songs: [],
        albums: [],
        artists: [],
        favorites: [],
        queued: [],
        interactions: [],
        users: [],
        settings: [],
        currentUser: null,
        playlists: [],
        useLastfm: false,
        allowDownload: false,
        currentVersion: '',
        latestVersion: '',
        cdnUrl: '',
    },

    init(successCb = null, errorCb = null) {
        this.reset();

        http.get('data', response => {
            const data = response.data;

            assign(this.state, data);

            // If this is a new user, initialize his preferences to be an empty object.
            if (!this.state.currentUser.preferences) {
                this.state.currentUser.preferences = {};
            }

            userStore.init(this.state.users, this.state.currentUser);<commit_msg>Disallow downloading on mobile altogether<commit_after>import { assign } from 'lodash';
import isMobile from 'ismobilejs';

import http from '../services/http';
import userStore from './user';
import preferenceStore from './preference';
import artistStore from './artist';
import songStore from './song';
import playlistStore from './playlist';
import queueStore from './queue';
import settingStore from './setting';

export default {
    state: {
        songs: [],
        albums: [],
        artists: [],
        favorites: [],
        queued: [],
        interactions: [],
        users: [],
        settings: [],
        currentUser: null,
        playlists: [],
        useLastfm: false,
        allowDownload: false,
        currentVersion: '',
        latestVersion: '',
        cdnUrl: '',
    },

    init(successCb = null, errorCb = null) {
        this.reset();

        http.get('data', response => {
            const data = response.data;

            // Don't allow downloading on mobile devices
            data.allowDownload = data.allowDownload && !isMobile.any;

            assign(this.state, data);

            // If this is a new user, initialize his preferences to be an empty object.
            if (!this.state.currentUser.preferences) {
                this.state.currentUser.preferences = {};
            }

            userStore.init(this.state.users, this.state.currentUser);
{'fraction_non_alphanumeric': 0.12972148035101105, 'fraction_numerical': 0.0, 'mean_word_length': 2.1251489868891538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5158915', 'n_tokens_mistral': 686, 'n_tokens_neox': 675, 'n_words': 192}