2018-10-25 06:33:15 +00:00
|
|
|
import Vue from 'vue';
|
2018-10-19 05:15:28 +00:00
|
|
|
|
|
|
|
export default {
|
2018-10-25 06:33:15 +00:00
|
|
|
SET_USER(state, data) {
|
2018-12-01 20:36:09 +00:00
|
|
|
state.isTouchDevice = ('ontouchstart' in window);
|
|
|
|
|
2018-10-25 06:33:15 +00:00
|
|
|
state.user = {
|
|
|
|
uid: data.uid,
|
|
|
|
displayName: data.displayName,
|
|
|
|
email: data.email,
|
|
|
|
emailVerified: data.emailVerified,
|
|
|
|
dateJoined: data.metadata.creationTime,
|
|
|
|
photoURL: data.photoURL,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_GAME_LISTS(state, lists) {
|
|
|
|
state.gameLists = lists;
|
|
|
|
},
|
|
|
|
|
|
|
|
CLEAR_SESSION(state) {
|
|
|
|
state.user = null;
|
2018-10-27 05:27:43 +00:00
|
|
|
state.authorizing = false;
|
2018-11-25 21:18:34 +00:00
|
|
|
state.activeList = null;
|
2018-11-27 23:59:19 +00:00
|
|
|
state.gameLists = {};
|
2018-10-27 05:27:43 +00:00
|
|
|
state.settings = null;
|
2018-11-25 21:18:34 +00:00
|
|
|
state.platform = null;
|
2018-10-27 05:27:43 +00:00
|
|
|
state.results = null;
|
2018-11-25 21:18:34 +00:00
|
|
|
state.games = {};
|
|
|
|
state.publicGameData = {};
|
2018-10-27 05:27:43 +00:00
|
|
|
state.game = null;
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
SET_SEARCH_RESULTS(state, results) {
|
|
|
|
state.results = results;
|
|
|
|
},
|
|
|
|
|
2018-10-25 06:33:15 +00:00
|
|
|
SET_AUTHORIZING_STATUS(state, status) {
|
|
|
|
state.authorizing = status;
|
|
|
|
},
|
|
|
|
|
2018-10-19 05:15:28 +00:00
|
|
|
CLEAR_SEARCH_RESULTS(state) {
|
|
|
|
state.results = [];
|
|
|
|
},
|
|
|
|
|
2018-11-17 22:20:54 +00:00
|
|
|
SET_ACTIVE_GAME(state, [game]) {
|
|
|
|
state.game = game;
|
|
|
|
},
|
|
|
|
|
|
|
|
CLEAR_ACTIVE_GAME(state) {
|
|
|
|
state.game = null;
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
SET_EDIT_GAME(state, { listId, gameId }) {
|
|
|
|
state.editGame = gameId;
|
|
|
|
state.activeList = listId;
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_ACTIVE_LIST(state, listIndex) {
|
|
|
|
state.activeList = listIndex;
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_PLATFORM(state, platform) {
|
|
|
|
state.platform = platform;
|
|
|
|
},
|
|
|
|
|
|
|
|
SORT_LIST(state, listIndex) {
|
2018-10-25 06:33:15 +00:00
|
|
|
const games = state.gameLists[state.platform.code][listIndex].games;
|
2018-10-19 05:15:28 +00:00
|
|
|
|
|
|
|
games.sort((a, b) => {
|
|
|
|
const gameA = state.games[a].name.toUpperCase();
|
|
|
|
const gameB = state.games[b].name.toUpperCase();
|
|
|
|
|
|
|
|
if (gameA < gameB) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gameA > gameB ? 1 : 0;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
UPDATE_LIST_NAME(state, { listIndex, listName }) {
|
2018-10-25 06:33:15 +00:00
|
|
|
state.gameLists[state.platform.code][listIndex].name = listName;
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
SET_SETTINGS(state, settings) {
|
2018-10-25 06:33:15 +00:00
|
|
|
state.settings = settings;
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
2018-11-25 21:18:34 +00:00
|
|
|
MOVE_LIST(state, { from, to }) {
|
|
|
|
const cutOut = state.gameLists[state.platform.code].splice(from, 1)[0];
|
|
|
|
state.gameLists[state.platform.code].splice(to, 0, cutOut);
|
|
|
|
},
|
|
|
|
|
2018-10-19 05:15:28 +00:00
|
|
|
REMOVE_LIST(state, index) {
|
2018-10-25 06:33:15 +00:00
|
|
|
state.gameLists[state.platform.code].splice(index, 1);
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
ADD_GAME(state, { gameId, listId }) {
|
2018-10-25 06:33:15 +00:00
|
|
|
const currentList = state.gameLists[state.platform.code][listId];
|
|
|
|
|
|
|
|
currentList.games.push(gameId);
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
ADD_LIST(state, listName) {
|
|
|
|
const newList = {
|
|
|
|
games: [],
|
|
|
|
name: listName,
|
|
|
|
};
|
|
|
|
|
2018-10-25 06:33:15 +00:00
|
|
|
if (!state.gameLists[state.platform.code]) {
|
|
|
|
Vue.set(state.gameLists, state.platform.code, []);
|
|
|
|
}
|
|
|
|
|
|
|
|
state.gameLists[state.platform.code].push(newList);
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
REMOVE_GAME(state, { gameId, listId }) {
|
2018-10-25 06:33:15 +00:00
|
|
|
const currentList = state.gameLists[state.platform.code][listId];
|
|
|
|
|
|
|
|
currentList.games.splice(currentList.games.indexOf(gameId), 1);
|
2018-10-19 05:15:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
CACHE_GAME_DATA(state, data) {
|
|
|
|
data.forEach((game) => {
|
2018-10-27 05:27:27 +00:00
|
|
|
Vue.set(state.games, game.id, { ...game });
|
2018-10-19 05:15:28 +00:00
|
|
|
});
|
|
|
|
},
|
2018-11-21 02:43:10 +00:00
|
|
|
|
|
|
|
SET_PUBLIC_GAME_DATA(state, data) {
|
|
|
|
data.forEach((game) => {
|
|
|
|
Vue.set(state.publicGameData, game.id, { ...game });
|
|
|
|
});
|
|
|
|
},
|
2018-10-19 05:15:28 +00:00
|
|
|
};
|