mirror of
https://github.com/romancm/gamebrary
synced 2025-02-26 11:47:10 +00:00
rename actions to differntiate between old/new
This commit is contained in:
parent
c9feaac712
commit
1617fbc71a
32 changed files with 117 additions and 411 deletions
|
@ -168,7 +168,7 @@ export default {
|
|||
},
|
||||
|
||||
async loadPlatforms() {
|
||||
this.platforms = await this.$store.dispatch('LOAD_PLATFORMS');
|
||||
this.platforms = await this.$store.dispatch('LOAD_IGDB_PLATFORMS');
|
||||
},
|
||||
|
||||
selectPlatform({ id, name }) {
|
||||
|
|
|
@ -453,7 +453,7 @@ export default {
|
|||
|
||||
this.$store.commit('SET_GAME_PROGRESS', payload);
|
||||
|
||||
await this.$store.dispatch('SAVE_PROGRESSES')
|
||||
await this.$store.dispatch('SAVE_PROGRESSES_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error saving your progress', { title: 'Error', variant: 'error' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -483,7 +483,7 @@ export default {
|
|||
|
||||
this.$store.commit('SET_GAME_NOTE', payload);
|
||||
|
||||
await this.$store.dispatch('SAVE_NOTES')
|
||||
await this.$store.dispatch('SAVE_NOTES_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error saving your note', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -497,7 +497,7 @@ export default {
|
|||
async deleteNote() {
|
||||
this.$store.commit('REMOVE_GAME_NOTE', this.gameId);
|
||||
|
||||
await this.$store.dispatch('SAVE_NOTES_NO_MERGE')
|
||||
await this.$store.dispatch('SAVE_NOTES_NO_MERGE_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error deleting your note', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -525,7 +525,7 @@ export default {
|
|||
eventValue: data,
|
||||
});
|
||||
|
||||
this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
// TODO: customize using cover image
|
||||
this.$bvToast.toast(`Added ${this.game.name} to list ${this.list.name}`, { title: 'Success', variant: 'success' });
|
||||
|
@ -545,7 +545,7 @@ export default {
|
|||
this.$store.commit('REMOVE_GAME', data);
|
||||
|
||||
this.$store
|
||||
.dispatch('SAVE_LIST', this.gameLists)
|
||||
.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
// TODO customize using cover
|
||||
this.$bvToast.toast(`Removed ${this.game.name} from list ${this.list.name}`, { title: 'Success', variant: 'success' });
|
||||
|
@ -601,7 +601,7 @@ export default {
|
|||
|
||||
this.$store.commit('REMOVE_GAME_PROGRESS', gameId);
|
||||
|
||||
await this.$store.dispatch('SAVE_PROGRESSES_NO_MERGE')
|
||||
await this.$store.dispatch('SAVE_PROGRESSES_NO_MERGE_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error deleting your progress', { title: 'Error', variant: 'error' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -95,7 +95,7 @@ export default {
|
|||
},
|
||||
|
||||
async saveTags() {
|
||||
await this.$store.dispatch('SAVE_TAGS', this.tags)
|
||||
await this.$store.dispatch('SAVE_TAGS_LEGACY', this.tags)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -113,7 +113,7 @@ export default {
|
|||
eventValue: data,
|
||||
});
|
||||
|
||||
this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
// TODO: customize, show cover url
|
||||
this.$bvToast.toast(`Added ${this.game.name} to list ${this.list.name}`, { title: 'Game added', variant: 'success' });
|
||||
|
@ -130,7 +130,7 @@ export default {
|
|||
},
|
||||
|
||||
async saveTags() {
|
||||
await this.$store.dispatch('SAVE_TAGS', this.tags)
|
||||
await this.$store.dispatch('SAVE_TAGS_LEGACY', this.tags)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -170,7 +170,7 @@ export default {
|
|||
},
|
||||
|
||||
async search() {
|
||||
await this.$store.dispatch('SEARCH', this.searchText)
|
||||
await this.$store.dispatch('SEARCH_LEGACY', this.searchText)
|
||||
.catch(({ data }) => {
|
||||
this.loading = false;
|
||||
this.error = data;
|
||||
|
|
|
@ -126,7 +126,7 @@ export default {
|
|||
|
||||
this.$store.commit('ADD_LIST', list);
|
||||
|
||||
this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
this.$bvToast.toast('List added', {
|
||||
variant: 'success',
|
||||
|
|
|
@ -94,7 +94,7 @@ export default {
|
|||
deleteBoard() {
|
||||
this.$store.commit('REMOVE_PLATFORM');
|
||||
|
||||
this.$store.dispatch('SAVE_LIST_NO_MERGE', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_NO_MERGE_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
this.$router.push({ name: 'platforms' });
|
||||
})
|
||||
|
@ -111,7 +111,7 @@ export default {
|
|||
//
|
||||
// gameLists[this.platform.code][this.listIndex].sortOrder = this.sortOrder;
|
||||
//
|
||||
// await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
// await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
// .catch(() => {
|
||||
// this.saving = false;
|
||||
//
|
||||
|
|
|
@ -136,7 +136,7 @@ export default {
|
|||
|
||||
gameLists[this.platform.code][this.listIndex].view = this.listView;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ export default {
|
|||
eventValue: data,
|
||||
});
|
||||
|
||||
this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
// TODO: customize, show cover url
|
||||
this.$bvToast.toast(`Added ${this.game.name} to list ${this.list.name}`, { title: 'Game added', variant: 'success' });
|
||||
|
@ -130,7 +130,7 @@ export default {
|
|||
},
|
||||
|
||||
async saveTags() {
|
||||
await this.$store.dispatch('SAVE_TAGS', this.tags)
|
||||
await this.$store.dispatch('SAVE_TAGS_LEGACY', this.tags)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -453,7 +453,7 @@ export default {
|
|||
|
||||
this.$store.commit('SET_GAME_PROGRESS', payload);
|
||||
|
||||
await this.$store.dispatch('SAVE_PROGRESSES')
|
||||
await this.$store.dispatch('SAVE_PROGRESSES_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error saving your progress', { title: 'Error', variant: 'error' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -483,7 +483,7 @@ export default {
|
|||
|
||||
this.$store.commit('SET_GAME_NOTE', payload);
|
||||
|
||||
await this.$store.dispatch('SAVE_NOTES')
|
||||
await this.$store.dispatch('SAVE_NOTES_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error saving your note', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -497,7 +497,7 @@ export default {
|
|||
async deleteNote() {
|
||||
this.$store.commit('REMOVE_GAME_NOTE', this.gameId);
|
||||
|
||||
await this.$store.dispatch('SAVE_NOTES_NO_MERGE')
|
||||
await this.$store.dispatch('SAVE_NOTES_NO_MERGE_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error deleting your note', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -525,7 +525,7 @@ export default {
|
|||
eventValue: data,
|
||||
});
|
||||
|
||||
this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
// TODO: customize using cover image
|
||||
this.$bvToast.toast(`Added ${this.game.name} to list ${this.list.name}`, { title: 'Success', variant: 'success' });
|
||||
|
@ -545,7 +545,7 @@ export default {
|
|||
this.$store.commit('REMOVE_GAME', data);
|
||||
|
||||
this.$store
|
||||
.dispatch('SAVE_LIST', this.gameLists)
|
||||
.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
// TODO customize using cover
|
||||
this.$bvToast.toast(`Removed ${this.game.name} from list ${this.list.name}`, { title: 'Success', variant: 'success' });
|
||||
|
@ -601,7 +601,7 @@ export default {
|
|||
|
||||
this.$store.commit('REMOVE_GAME_PROGRESS', gameId);
|
||||
|
||||
await this.$store.dispatch('SAVE_PROGRESSES_NO_MERGE')
|
||||
await this.$store.dispatch('SAVE_PROGRESSES_NO_MERGE_LEGACY')
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('There was an error deleting your progress', { title: 'Error', variant: 'error' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -95,7 +95,7 @@ export default {
|
|||
},
|
||||
|
||||
async saveTags() {
|
||||
await this.$store.dispatch('SAVE_TAGS', this.tags)
|
||||
await this.$store.dispatch('SAVE_TAGS_LEGACY', this.tags)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -1,300 +0,0 @@
|
|||
<template lang="html">
|
||||
<div :class="['list mr-3', viewClass, { unique, dragging }]">
|
||||
<b-card no-body>
|
||||
<b-card-header
|
||||
class="py-0 pr-0 pl-2 d-flex justify-content-between align-items-center"
|
||||
>
|
||||
<h6 class="m-0">
|
||||
<b-badge v-if="autoSortEnabled">
|
||||
<b-icon-sort-up />
|
||||
</b-badge>
|
||||
|
||||
<b-badge v-if="list[listIndex].showGameCount">
|
||||
{{ gameList.length }}
|
||||
</b-badge>
|
||||
|
||||
{{ list[listIndex].name }}
|
||||
</h6>
|
||||
|
||||
<b-button-group>
|
||||
<add-game-modal :list-id="listIndex" />
|
||||
<list-settings :list-index="listIndex" />
|
||||
</b-button-group>
|
||||
</b-card-header>
|
||||
|
||||
<draggable
|
||||
class="games"
|
||||
:list="gameList"
|
||||
:id="listIndex"
|
||||
:move="validateMove"
|
||||
v-bind="gameDraggableOptions"
|
||||
@end="dragEnd"
|
||||
@start="dragStart"
|
||||
>
|
||||
<component
|
||||
v-for="game in sortedGames"
|
||||
:is="gameCardComponent"
|
||||
:key="game"
|
||||
:id="game"
|
||||
:game-id="game"
|
||||
:list-id="listIndex"
|
||||
/>
|
||||
|
||||
<b-button
|
||||
variant="light"
|
||||
block
|
||||
v-if="isEmpty"
|
||||
class="mb-2"
|
||||
v-b-modal="`game-modal-${listIndex}`"
|
||||
>
|
||||
Click here or drag games here
|
||||
</b-button>
|
||||
</draggable>
|
||||
</b-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import draggable from 'vuedraggable';
|
||||
import ListSettings from '@/components/LegacyBoard/ListSettings';
|
||||
import GameCardDefault from '@/components/LegacyBoard/LegacyGameCardDefault';
|
||||
import GameCardGrid from '@/components/LegacyBoard/LegacyGameCardGrid';
|
||||
import GameCardCompact from '@/components/LegacyBoard/LegacyGameCardCompact';
|
||||
import GameCardText from '@/components/LegacyBoard/LegacyGameCardText';
|
||||
import AddGameModal from '@/components/LegacyBoard/AddGameModal';
|
||||
import orderby from 'lodash.orderby';
|
||||
import { mapState } from 'vuex';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GameCardDefault,
|
||||
GameCardGrid,
|
||||
GameCardCompact,
|
||||
GameCardText,
|
||||
AddGameModal,
|
||||
ListSettings,
|
||||
draggable,
|
||||
},
|
||||
|
||||
props: {
|
||||
name: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
gameList: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
listIndex: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
gameDraggableOptions: {
|
||||
handle: '.game-card',
|
||||
ghostClass: 'card-placeholder',
|
||||
filter: '.drag-filter',
|
||||
delay: 100,
|
||||
delayOnTouchOnly: true,
|
||||
animation: 500,
|
||||
group: {
|
||||
name: 'games',
|
||||
},
|
||||
},
|
||||
gameCardComponents: {
|
||||
single: 'GameCardDefault',
|
||||
grid: 'GameCardGrid',
|
||||
compact: 'GameCardCompact',
|
||||
text: 'GameCardText',
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['user', 'gameLists', 'platform', 'settings', 'games', 'dragging', 'progresses']),
|
||||
|
||||
autoSortEnabled() {
|
||||
const list = this.list[this.listIndex];
|
||||
|
||||
return list && list.sortOrder && list.sortOrder !== 'sortByCustom';
|
||||
},
|
||||
|
||||
sortedGames() {
|
||||
const sortOrder = this.list[this.listIndex].sortOrder || 'sortByCustom';
|
||||
const { gameList } = this;
|
||||
|
||||
// TODO: use lodash to clean things up a bit here
|
||||
|
||||
switch (sortOrder) {
|
||||
case 'sortByCustom':
|
||||
return gameList;
|
||||
case 'sortByProgress':
|
||||
return orderby(gameList, [(game) => {
|
||||
const progress = this.games[game]
|
||||
&& this.progresses[this.platform.code][this.games[game].id]
|
||||
? Number(this.progresses[this.platform.code][this.games[game].id])
|
||||
: 0;
|
||||
|
||||
return progress;
|
||||
}], ['desc']);
|
||||
case 'sortByRating':
|
||||
return orderby(gameList, [(game) => {
|
||||
const rating = this.games[game] && this.games[game].rating
|
||||
? this.games[game].rating
|
||||
: 0;
|
||||
|
||||
return rating;
|
||||
}], ['desc']);
|
||||
case 'sortByName':
|
||||
return orderby(gameList, [(game) => {
|
||||
const name = this.games[game] && this.games[game].name
|
||||
? this.games[game].name.toUpperCase()
|
||||
: '';
|
||||
|
||||
return name;
|
||||
}]);
|
||||
case 'sortByReleaseDate':
|
||||
return orderby(gameList, [(game) => {
|
||||
const releaseDate = this.games[game] && this.games[game].release_dates
|
||||
? this.games[game].release_dates
|
||||
.find(({ platform }) => this.platform.id === platform)
|
||||
: '';
|
||||
|
||||
return releaseDate && releaseDate.date;
|
||||
}]);
|
||||
default:
|
||||
return gameList;
|
||||
}
|
||||
},
|
||||
|
||||
list() {
|
||||
return this.gameLists[this.platform.code];
|
||||
},
|
||||
|
||||
isEmpty() {
|
||||
return this.gameList.length === 0;
|
||||
},
|
||||
|
||||
view() {
|
||||
return this.list[this.listIndex].view;
|
||||
},
|
||||
|
||||
unique() {
|
||||
return this.list.length === 1;
|
||||
},
|
||||
|
||||
showGameCount() {
|
||||
return this.settings[this.platform.code] && this.settings[this.platform.code].showGameCount;
|
||||
},
|
||||
|
||||
gameCardComponent() {
|
||||
return this.view && Object.keys(this.gameCardComponents).includes(this.view)
|
||||
? this.gameCardComponents[this.view]
|
||||
: 'GameCardDefault';
|
||||
},
|
||||
|
||||
viewClass() {
|
||||
return this.list[this.listIndex].view || 'single';
|
||||
},
|
||||
|
||||
showGameRatings() {
|
||||
return this.list[this.listIndex].showGameRatings || false;
|
||||
},
|
||||
|
||||
hideReleaseDates() {
|
||||
return this.list[this.listIndex].hideReleaseDates || false;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
validateMove({ from, to }) {
|
||||
const isDifferentList = from.id !== to.id;
|
||||
const isDuplicate = this.list[to.id].games.includes(Number(this.draggingId));
|
||||
const validMove = isDifferentList && isDuplicate;
|
||||
return !validMove;
|
||||
},
|
||||
|
||||
dragStart({ item }) {
|
||||
this.$store.commit('SET_DRAGGING_STATUS', true);
|
||||
this.draggingId = item.id;
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (window.innerWidth <= 780) {
|
||||
window.navigator.vibrate([100]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
dragEnd() {
|
||||
this.$store.commit('SET_DRAGGING_STATUS', false);
|
||||
this.$emit('dragEnd');
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" rel="stylesheet/scss" scoped>
|
||||
.list {
|
||||
flex-shrink: 0;
|
||||
cursor: default;
|
||||
position: relative;
|
||||
width: 300px;
|
||||
border-radius: 3px;
|
||||
|
||||
&.unique {
|
||||
@media(max-width: 780px) {
|
||||
min-width: 300px;
|
||||
width: calc(100vw - 80px);
|
||||
}
|
||||
}
|
||||
|
||||
.games {
|
||||
display: grid;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
max-height: calc(100vh - 144px);
|
||||
overflow-y: auto;
|
||||
padding: .5rem .5rem 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&.grid {
|
||||
.games {
|
||||
padding: .5rem;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: .5rem;
|
||||
|
||||
// https://github.com/w3c/csswg-drafts/issues/129
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
height: 1px;
|
||||
margin-top: -1px;
|
||||
width: 100%;
|
||||
grid-column: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
&.unique {
|
||||
.games {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
|
||||
// @media($tiny) {
|
||||
// grid-template-columns: 1fr 1fr;
|
||||
// }
|
||||
|
||||
@media(min-width: 781px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.list-settings {
|
||||
padding: 1rem;
|
||||
}
|
||||
</style>
|
|
@ -128,7 +128,7 @@ export default {
|
|||
async deleteList() {
|
||||
this.$store.commit('REMOVE_LIST', this.listIndex);
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -142,7 +142,7 @@ export default {
|
|||
async moveList(from, to) {
|
||||
this.$store.commit('MOVE_LIST', { from, to });
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -128,7 +128,7 @@ export default {
|
|||
async deleteList() {
|
||||
this.$store.commit('REMOVE_LIST', this.listIndex);
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -142,7 +142,7 @@ export default {
|
|||
async moveList(from, to) {
|
||||
this.$store.commit('MOVE_LIST', { from, to });
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -118,7 +118,7 @@ export default {
|
|||
gameLists[this.platform.code][this.listIndex].showGameTags = this.showGameTags;
|
||||
gameLists[this.platform.code][this.listIndex].showGameCount = this.showGameCount;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ export default {
|
|||
|
||||
methods: {
|
||||
saveSettings() {
|
||||
this.$store.dispatch('SAVE_SETTINGS', this.settings)
|
||||
this.$store.dispatch('SAVE_SETTINGS_LEGACY', this.settings)
|
||||
.then(() => {
|
||||
this.$bvToast.toast('Settings saved', { title: 'Success', variant: 'success' });
|
||||
})
|
||||
|
|
|
@ -110,7 +110,7 @@ export default {
|
|||
|
||||
gameLists[this.platform.code][this.listIndex].name = this.listName;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ export default {
|
|||
|
||||
gameLists[this.platform.code][this.listIndex].sortOrder = this.sortOrder;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -304,8 +304,8 @@ export default {
|
|||
|
||||
async saveTags(editing) {
|
||||
const action = editing
|
||||
? 'SAVE_TAGS_NO_MERGE'
|
||||
: 'SAVE_TAGS';
|
||||
? 'SAVE_TAGS_NO_MERGE_LEGACY'
|
||||
: 'SAVE_TAGS_LEGACY';
|
||||
|
||||
await this.$store.dispatch(action, this.localTags)
|
||||
.catch(() => {
|
||||
|
|
|
@ -170,7 +170,7 @@ export default {
|
|||
},
|
||||
|
||||
async search() {
|
||||
await this.$store.dispatch('SEARCH', this.searchText)
|
||||
await this.$store.dispatch('SEARCH_LEGACY', this.searchText)
|
||||
.catch(({ data }) => {
|
||||
this.loading = false;
|
||||
this.error = data;
|
||||
|
|
|
@ -136,7 +136,7 @@ export default {
|
|||
|
||||
gameLists[this.platform.code][this.listIndex].view = this.listView;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ export default {
|
|||
async deleteList() {
|
||||
this.$store.commit('REMOVE_LIST', this.listIndex);
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -142,7 +142,7 @@ export default {
|
|||
async moveList(from, to) {
|
||||
this.$store.commit('MOVE_LIST', { from, to });
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
|
|
@ -118,7 +118,7 @@ export default {
|
|||
gameLists[this.platform.code][this.listIndex].showGameTags = this.showGameTags;
|
||||
gameLists[this.platform.code][this.listIndex].showGameCount = this.showGameCount;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ export default {
|
|||
|
||||
gameLists[this.platform.code][this.listIndex].name = this.listName;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ export default {
|
|||
|
||||
gameLists[this.platform.code][this.listIndex].sortOrder = this.sortOrder;
|
||||
|
||||
await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
.catch(() => {
|
||||
this.saving = false;
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ export default {
|
|||
deleteBoard() {
|
||||
this.$store.commit('REMOVE_PLATFORM');
|
||||
|
||||
this.$store.dispatch('SAVE_LIST_NO_MERGE', this.gameLists)
|
||||
this.$store.dispatch('SAVE_LIST_NO_MERGE_LEGACY', this.gameLists)
|
||||
.then(() => {
|
||||
this.$router.push({ name: 'platforms' });
|
||||
})
|
||||
|
@ -111,7 +111,7 @@ export default {
|
|||
//
|
||||
// gameLists[this.platform.code][this.listIndex].sortOrder = this.sortOrder;
|
||||
//
|
||||
// await this.$store.dispatch('SAVE_LIST', gameLists)
|
||||
// await this.$store.dispatch('SAVE_LIST_LEGACY', gameLists)
|
||||
// .catch(() => {
|
||||
// this.saving = false;
|
||||
//
|
||||
|
|
|
@ -304,8 +304,8 @@ export default {
|
|||
|
||||
async saveTags(editing) {
|
||||
const action = editing
|
||||
? 'SAVE_TAGS_NO_MERGE'
|
||||
: 'SAVE_TAGS';
|
||||
? 'SAVE_TAGS_NO_MERGE_LEGACY'
|
||||
: 'SAVE_TAGS_LEGACY';
|
||||
|
||||
await this.$store.dispatch(action, this.localTags)
|
||||
.catch(() => {
|
||||
|
|
|
@ -81,7 +81,7 @@ export default {
|
|||
wallpapers: this.wallpapers,
|
||||
};
|
||||
|
||||
this.$store.dispatch('SAVE_SETTINGS', settings)
|
||||
this.$store.dispatch('SAVE_SETTINGS_LEGACY', settings)
|
||||
.then(() => {
|
||||
this.$bvToast.toast('Settings saved', { title: 'Success', variant: 'success' });
|
||||
this.loading = false;
|
||||
|
|
|
@ -66,7 +66,7 @@ export default {
|
|||
},
|
||||
|
||||
async updateLists() {
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -93,7 +93,7 @@ export default {
|
|||
loadBoardGames() {
|
||||
const { lists } = this.board;
|
||||
|
||||
if (lists.length = 0) {
|
||||
if (lists.length === 0) {
|
||||
return this.$bvModal.show('add-list');
|
||||
}
|
||||
|
||||
|
@ -101,8 +101,11 @@ export default {
|
|||
? lists.map(({ games }) => games).flat()
|
||||
: [];
|
||||
|
||||
// eslint-disable-next-line
|
||||
console.log(boardGames);
|
||||
|
||||
return boardGames;
|
||||
|
||||
// if (!hasLists && flattenedList.length === 0) {
|
||||
// }
|
||||
//
|
||||
|
|
|
@ -78,7 +78,7 @@ export default {
|
|||
},
|
||||
|
||||
async updateLists() {
|
||||
await this.$store.dispatch('SAVE_LIST', this.gameLists)
|
||||
await this.$store.dispatch('SAVE_LIST_LEGACY', this.gameLists)
|
||||
.catch(() => {
|
||||
this.$bvToast.toast('Authentication error', { title: 'Error', variant: 'danger' });
|
||||
this.$router.push({ name: 'sessionExpired' });
|
||||
|
@ -111,7 +111,7 @@ export default {
|
|||
this.loading = true;
|
||||
|
||||
this.$store
|
||||
.dispatch('LOAD_GAMES', gameList.toString())
|
||||
.dispatch('LOAD_GAMES_LEGACY', gameList.toString())
|
||||
.then(() => {
|
||||
this.loading = false;
|
||||
})
|
||||
|
|
|
@ -6,17 +6,11 @@ import 'firebase/firestore';
|
|||
const API_BASE = 'http://localhost:5001/gamebrary-8c736/us-central1';
|
||||
|
||||
export default {
|
||||
LOAD_GAMES({ commit }, gameList) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/games?games=${gameList}`)
|
||||
.then(({ data }) => {
|
||||
commit('CACHE_GAME_DATA', data);
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
//
|
||||
// NEW STUFF
|
||||
//
|
||||
|
||||
LOAD_PLATFORMS() {
|
||||
LOAD_IGDB_PLATFORMS() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/platforms`)
|
||||
.then(({ data }) => {
|
||||
|
@ -25,15 +19,6 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_LIST({ commit, state }, payload) {
|
||||
const db = firebase.firestore();
|
||||
|
||||
db.collection('lists').doc(state.user.uid).set(payload, { merge: true })
|
||||
.then(() => {
|
||||
commit('SAVE_LISTS', payload);
|
||||
});
|
||||
},
|
||||
|
||||
LOAD_BOARDS({ state, commit }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = firebase.firestore();
|
||||
|
@ -115,7 +100,30 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_PROGRESSES({ state }) {
|
||||
//
|
||||
// LEGACY
|
||||
//
|
||||
|
||||
LOAD_GAMES_LEGACY({ commit }, gameList) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/games?games=${gameList}`)
|
||||
.then(({ data }) => {
|
||||
commit('CACHE_GAME_DATA', data);
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
SAVE_LIST_LEGACY({ commit, state }, payload) {
|
||||
const db = firebase.firestore();
|
||||
|
||||
db.collection('lists').doc(state.user.uid).set(payload, { merge: true })
|
||||
.then(() => {
|
||||
commit('SAVE_LIST_LEGACYS', payload);
|
||||
});
|
||||
},
|
||||
|
||||
SAVE_PROGRESSES_LEGACY({ state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = firebase.firestore();
|
||||
|
||||
|
@ -125,7 +133,7 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_PROGRESSES_NO_MERGE({ state }) {
|
||||
SAVE_PROGRESSES_NO_MERGE_LEGACY({ state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = firebase.firestore();
|
||||
|
||||
|
@ -135,7 +143,7 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_TAGS({ state }, tags) {
|
||||
SAVE_TAGS_LEGACY({ state }, tags) {
|
||||
const db = firebase.firestore();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -145,7 +153,7 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_TAGS_NO_MERGE({ state }, tags) {
|
||||
SAVE_TAGS_NO_MERGE_LEGACY({ state }, tags) {
|
||||
const db = firebase.firestore();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -155,7 +163,7 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_NOTES({ state }) {
|
||||
SAVE_NOTES_LEGACY({ state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = firebase.firestore();
|
||||
|
||||
|
@ -165,7 +173,7 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_NOTES_NO_MERGE({ state }) {
|
||||
SAVE_NOTES_NO_MERGE_LEGACY({ state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const db = firebase.firestore();
|
||||
|
||||
|
@ -175,16 +183,16 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SAVE_LIST_NO_MERGE({ commit, state }, payload) {
|
||||
SAVE_LIST_NO_MERGE_LEGACY({ commit, state }, payload) {
|
||||
const db = firebase.firestore();
|
||||
|
||||
db.collection('lists').doc(state.user.uid).set(payload, { merge: false })
|
||||
.then(() => {
|
||||
commit('SAVE_LISTS', payload);
|
||||
commit('SAVE_LIST_LEGACYS', payload);
|
||||
});
|
||||
},
|
||||
|
||||
SAVE_SETTINGS({ commit, state }, settings) {
|
||||
SAVE_SETTINGS_LEGACY({ commit, state }, settings) {
|
||||
const db = firebase.firestore();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -197,6 +205,33 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
SEARCH_LEGACY({ commit, state }, searchText) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/search?search=${searchText}&platform=${state.platform.id}`)
|
||||
.then(({ data }) => {
|
||||
commit('SET_SEARCH_RESULTS', data);
|
||||
commit('CACHE_GAME_DATA', data);
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
//
|
||||
// STUFF THAT REMAINS THE SAME
|
||||
//
|
||||
|
||||
// TODO: use firebase email extension instead
|
||||
SEND_WELCOME_EMAIL(context, additionalUserInfo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (additionalUserInfo && additionalUserInfo.profile) {
|
||||
axios.get(`${API_BASE}/email?address=${additionalUserInfo.profile.email}&template_id=welcome`)
|
||||
.catch(reject);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
LOAD_RELEASES() {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('https://api.github.com/repos/romancm/gamebrary/releases')
|
||||
|
@ -224,16 +259,6 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
LOAD_PUBLIC_GAMES({ commit }, gameList) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/games?games=${gameList}`)
|
||||
.then(({ data }) => {
|
||||
commit('SET_PUBLIC_GAME_DATA', data);
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
LOAD_GAME(context, gameId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/game?gameId=${gameId}`)
|
||||
|
@ -244,26 +269,4 @@ export default {
|
|||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
SEARCH({ commit, state }, searchText) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(`${API_BASE}/search?search=${searchText}&platform=${state.platform.id}`)
|
||||
.then(({ data }) => {
|
||||
commit('SET_SEARCH_RESULTS', data);
|
||||
commit('CACHE_GAME_DATA', data);
|
||||
resolve();
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
SEND_WELCOME_EMAIL(context, additionalUserInfo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (additionalUserInfo && additionalUserInfo.profile) {
|
||||
axios.get(`${API_BASE}/email?address=${additionalUserInfo.profile.email}&template_id=welcome`)
|
||||
.catch(reject);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -153,7 +153,7 @@ export default {
|
|||
state.platform = platform;
|
||||
},
|
||||
|
||||
SAVE_LISTS(state, lists) {
|
||||
SAVE_LIST_LEGACYS(state, lists) {
|
||||
state.gameLists = lists;
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue