2018-10-25 06:33:15 +00:00
|
|
|
import Vue from 'vue';
|
2020-08-25 04:21:24 +00:00
|
|
|
import { PLATFORM_CATEGORIES, EXCLUDED_PLATFORMS, PLATFORM_BG_HEX, PLATFORM_LOGO_FORMAT, PLATFORM_NAME_OVERRIDES, POPULAR_PLATFORMS } from '@/constants';
|
2018-10-19 05:15:28 +00:00
|
|
|
|
|
|
|
export default {
|
2020-08-18 18:56:10 +00:00
|
|
|
SET_BOARDS(state, boards) {
|
|
|
|
state.boards = boards;
|
|
|
|
},
|
|
|
|
|
2020-09-01 22:38:45 +00:00
|
|
|
SET_RELEASES(state, releases) {
|
|
|
|
state.releases = releases;
|
|
|
|
},
|
|
|
|
|
2020-08-25 04:21:24 +00:00
|
|
|
CLEAR_BOARD(state) {
|
|
|
|
state.board = {};
|
|
|
|
},
|
|
|
|
|
2020-08-18 22:01:16 +00:00
|
|
|
SET_BOARD(state, board) {
|
|
|
|
state.board = board;
|
|
|
|
},
|
|
|
|
|
2020-09-01 17:43:48 +00:00
|
|
|
UPDATE_BOARD_NAME(state, updatedBoard) {
|
|
|
|
const board = state.boards.find(({ id }) => updatedBoard.id === id);
|
|
|
|
|
|
|
|
board.name = updatedBoard.name;
|
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
SET_GAME_BOARD(state, board) {
|
|
|
|
state.board = board;
|
|
|
|
},
|
|
|
|
|
2020-08-22 12:21:56 +00:00
|
|
|
SET_PLATFORMS(state, platforms) {
|
2020-08-25 04:21:24 +00:00
|
|
|
state.platforms = platforms
|
|
|
|
.filter(({ id }) => !EXCLUDED_PLATFORMS.includes(id))
|
|
|
|
.map((platform) => {
|
|
|
|
const formattedPlatform = {
|
|
|
|
id: platform.id,
|
|
|
|
name: PLATFORM_NAME_OVERRIDES[platform.id] || platform.name,
|
|
|
|
slug: platform.slug,
|
|
|
|
category: PLATFORM_CATEGORIES[platform.category],
|
|
|
|
popular: POPULAR_PLATFORMS.includes(platform.id),
|
|
|
|
// categoryId: platform.category,
|
|
|
|
generation: platform.generation || 0,
|
|
|
|
bgHex: PLATFORM_BG_HEX[platform.id] || null,
|
2020-08-26 18:06:47 +00:00
|
|
|
logoFormat: PLATFORM_LOGO_FORMAT[platform.id] || 'svg',
|
2020-08-25 04:21:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return formattedPlatform;
|
|
|
|
});
|
2020-08-22 12:21:56 +00:00
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
SET_BOARD_GAMES(state, boardGames) {
|
|
|
|
state.boardGames = boardGames;
|
|
|
|
},
|
|
|
|
|
2020-08-25 23:37:33 +00:00
|
|
|
SET_WALLPAPERS(state, wallpapers) {
|
|
|
|
state.wallpapers = wallpapers;
|
|
|
|
},
|
|
|
|
|
|
|
|
REMOVE_WALLPAPER(state, fullPath) {
|
|
|
|
const wallpaperIndex = state.wallpapers.findIndex(wallpaper => wallpaper.fullPath === fullPath);
|
|
|
|
|
|
|
|
state.wallpapers.splice(wallpaperIndex, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
ADD_WALLPAPER(state, wallpaper) {
|
|
|
|
state.wallpapers.push(wallpaper);
|
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
ADD_BOARD(state, board) {
|
|
|
|
state.boards.push(board);
|
|
|
|
},
|
|
|
|
|
2020-08-21 06:13:45 +00:00
|
|
|
ADD_LIST(state, list) {
|
|
|
|
state.board.lists.push(list);
|
|
|
|
},
|
|
|
|
|
2020-08-18 18:56:10 +00:00
|
|
|
REMOVE_BOARD(state, boardId) {
|
|
|
|
const boardIndex = state.boards.findIndex(({ id }) => id === boardId);
|
|
|
|
|
|
|
|
state.boards.splice(boardIndex, 1);
|
|
|
|
},
|
|
|
|
|
2020-08-15 00:02:34 +00:00
|
|
|
SET_GAME_MODAL_DATA(state, gameModalData) {
|
|
|
|
state.gameModalData = gameModalData;
|
|
|
|
},
|
|
|
|
|
|
|
|
CLEAR_GAME_MODAL_DATA(state) {
|
|
|
|
state.gameModalData = null;
|
|
|
|
},
|
|
|
|
|
2020-08-22 12:22:51 +00:00
|
|
|
ADD_GAME_TO_LIST({ board }, { listIndex, game }) {
|
|
|
|
board.lists[listIndex].games.push(game.id);
|
|
|
|
},
|
|
|
|
|
|
|
|
REMOVE_GAME_FROM_LIST({ board }, { listIndex, game }) {
|
|
|
|
const currentList = board.lists[listIndex];
|
|
|
|
|
|
|
|
currentList.games.splice(currentList.games.indexOf(game.id), 1);
|
2020-08-21 06:13:45 +00:00
|
|
|
},
|
|
|
|
|
2020-08-21 06:49:49 +00:00
|
|
|
REMOVE_LIST(state, index) {
|
|
|
|
state.board.lists.splice(index, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
MOVE_LIST(state, { from, to }) {
|
|
|
|
const cutOut = state.board.lists.splice(from, 1)[0];
|
|
|
|
|
|
|
|
state.board.lists.splice(to, 0, cutOut);
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_LIST_SORT_ORDER(state, { listIndex, sortOrder }) {
|
|
|
|
Vue.set(state.board.lists[listIndex].settings, 'sortOrder', sortOrder);
|
|
|
|
},
|
|
|
|
|
2020-08-21 07:43:30 +00:00
|
|
|
SET_LIST_VIEW(state, { listIndex, view }) {
|
|
|
|
Vue.set(state.board.lists[listIndex].settings, 'view', view);
|
|
|
|
},
|
|
|
|
|
2020-08-21 14:38:03 +00:00
|
|
|
SET_LIST_SETTINGS(state, { listIndex, settings }) {
|
|
|
|
Vue.set(state.board.lists[listIndex], 'settings', settings);
|
|
|
|
},
|
|
|
|
|
2020-08-21 07:43:30 +00:00
|
|
|
RENAME_LIST(state, { listIndex, listName }) {
|
|
|
|
state.board.lists[listIndex].name = listName;
|
|
|
|
},
|
|
|
|
|
2020-08-18 22:01:16 +00:00
|
|
|
SET_USER(state, data) {
|
|
|
|
state.user = {
|
|
|
|
lastLogin: data.metadata.lastSignInTime,
|
|
|
|
uid: data.uid,
|
|
|
|
displayName: data.displayName,
|
|
|
|
email: data.email,
|
|
|
|
emailVerified: data.emailVerified,
|
|
|
|
dateJoined: data.metadata.creationTime,
|
|
|
|
photoURL: data.photoURL,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
CACHE_GAME_DATA(state, data) {
|
|
|
|
data.forEach((game) => {
|
|
|
|
Vue.set(state.games, game.id, { ...game });
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_SETTINGS(state, settings) {
|
|
|
|
state.settings = settings;
|
|
|
|
},
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
UPDATE_TAG(state, { tagName, tagHex, tempTag }) {
|
|
|
|
const updatedTag = {
|
|
|
|
...state.tags[tempTag.tagName],
|
|
|
|
hex: tagHex,
|
|
|
|
};
|
|
|
|
|
|
|
|
const renaming = tagName !== tempTag.tagName;
|
|
|
|
|
|
|
|
if (renaming) {
|
|
|
|
Vue.set(state.tags, tagName, updatedTag);
|
|
|
|
Vue.delete(state.tags, tempTag.tagName);
|
|
|
|
} else {
|
|
|
|
state.tags[tempTag.tagName] = updatedTag;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_TAGS(state, tags) {
|
|
|
|
state.tags = tags;
|
|
|
|
},
|
|
|
|
|
2020-08-18 22:01:16 +00:00
|
|
|
CLEAR_SESSION(state) {
|
|
|
|
state.user = null;
|
2020-08-26 04:44:59 +00:00
|
|
|
state.tags = {};
|
|
|
|
state.notes = {};
|
|
|
|
state.progresses = {};
|
|
|
|
state.dragging = false;
|
2020-08-18 22:01:16 +00:00
|
|
|
state.gameLists = {};
|
|
|
|
state.settings = null;
|
|
|
|
state.platform = null;
|
2020-08-26 04:44:59 +00:00
|
|
|
state.platforms = [];
|
|
|
|
state.results = [];
|
2020-08-18 22:01:16 +00:00
|
|
|
state.games = {};
|
2020-08-26 04:44:59 +00:00
|
|
|
state.boards = [];
|
|
|
|
state.board = {};
|
|
|
|
state.boardGames = [];
|
|
|
|
state.gameModalData = null;
|
|
|
|
state.wallpaperUrl = null;
|
|
|
|
state.wallpapers = [];
|
2019-12-16 19:05:52 +00:00
|
|
|
},
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
SET_NOTES(state, notes) {
|
|
|
|
state.notes = notes;
|
|
|
|
},
|
|
|
|
|
2019-12-17 05:05:35 +00:00
|
|
|
SET_PROGRESSES(state, progresses) {
|
|
|
|
state.progresses = progresses;
|
|
|
|
},
|
|
|
|
|
2020-08-15 20:41:43 +00:00
|
|
|
REMOVE_GAME_PROGRESS({ progresses }, gameId) {
|
|
|
|
if (progresses[gameId]) {
|
|
|
|
Vue.delete(progresses, gameId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_GAME_PROGRESS(state, { progress, gameId }) {
|
|
|
|
state.progresses[gameId] = progress;
|
|
|
|
},
|
2019-12-18 05:47:35 +00:00
|
|
|
|
2020-08-15 22:39:22 +00:00
|
|
|
SET_GAME_NOTE(state, { note, gameId }) {
|
|
|
|
state.notes[gameId] = note;
|
2019-12-18 23:03:57 +00:00
|
|
|
},
|
|
|
|
|
2020-08-18 22:01:16 +00:00
|
|
|
SET_DRAGGING_STATUS(state, status) {
|
|
|
|
state.dragging = status;
|
|
|
|
},
|
|
|
|
|
2020-08-15 22:39:22 +00:00
|
|
|
REMOVE_GAME_NOTE(state, gameId) {
|
|
|
|
if (state.notes[gameId]) {
|
|
|
|
Vue.delete(state.notes, gameId);
|
2019-12-18 23:03:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
ADD_GAME_TAG(state, { tagName, gameId }) {
|
|
|
|
state.tags[tagName].games.push(gameId);
|
|
|
|
},
|
|
|
|
|
|
|
|
REMOVE_GAME_TAG(state, { tagName, gameId }) {
|
|
|
|
state.tags[tagName].games.splice(state.tags[tagName].games.indexOf(gameId), 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_SEARCH_RESULTS(state, results) {
|
|
|
|
state.results = results;
|
|
|
|
},
|
|
|
|
|
|
|
|
CLEAR_SEARCH_RESULTS(state) {
|
|
|
|
state.results = [];
|
|
|
|
},
|
|
|
|
|
2019-12-13 06:53:37 +00:00
|
|
|
UPDATE_SETTING(state, { key, value }) {
|
|
|
|
state.settings[key] = value;
|
|
|
|
},
|
2020-09-09 20:38:52 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// LEGACY STUFF
|
|
|
|
//
|
|
|
|
|
|
|
|
SET_ACTIVE_PLATFORM_LEGACY(state, platform) {
|
|
|
|
state.platform = platform;
|
|
|
|
},
|
|
|
|
|
|
|
|
SAVE_LIST_LEGACY(state, lists) {
|
|
|
|
state.gameLists = lists;
|
|
|
|
},
|
|
|
|
|
|
|
|
REMOVE_PLATFORM_LEGACY(state) {
|
|
|
|
Vue.delete(state.gameLists, state.platform.code);
|
|
|
|
},
|
|
|
|
|
|
|
|
SET_GAME_LISTS_LEGACY(state, lists) {
|
|
|
|
state.gameLists = lists;
|
|
|
|
},
|
2018-10-19 05:15:28 +00:00
|
|
|
};
|