2018-10-19 05:15:28 +00:00
|
|
|
<template>
|
2019-11-08 20:34:06 +00:00
|
|
|
<div
|
|
|
|
id="app"
|
|
|
|
:dir="dir"
|
|
|
|
>
|
2021-02-03 04:58:55 +00:00
|
|
|
<dock />
|
2021-02-01 21:16:03 +00:00
|
|
|
<global-modals />
|
2020-10-31 17:44:15 +00:00
|
|
|
|
2021-02-01 21:16:03 +00:00
|
|
|
<main :class="{ 'authorizing': !user, 'bg-dark text-white': nightMode }">
|
2020-09-26 00:09:20 +00:00
|
|
|
<router-view />
|
|
|
|
</main>
|
2019-11-08 20:34:06 +00:00
|
|
|
</div>
|
2018-10-19 05:15:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-01-10 19:55:45 +00:00
|
|
|
import Dock from '@/components/Dock';
|
2021-02-01 21:16:03 +00:00
|
|
|
import GlobalModals from '@/components/GlobalModals';
|
2018-11-05 02:28:29 +00:00
|
|
|
import firebase from 'firebase/app';
|
2020-10-14 00:38:35 +00:00
|
|
|
import { mapState, mapGetters } from 'vuex';
|
2018-11-05 02:28:29 +00:00
|
|
|
import 'firebase/firestore';
|
2018-10-25 06:33:15 +00:00
|
|
|
|
2020-08-15 00:00:04 +00:00
|
|
|
// TODO: store in env vars
|
2018-11-05 02:28:29 +00:00
|
|
|
firebase.initializeApp({
|
2019-11-08 19:56:03 +00:00
|
|
|
apiKey: 'AIzaSyA6MsmnLtqT4b11r-j15wwreRypO3AodcA',
|
|
|
|
authDomain: 'gamebrary.com',
|
|
|
|
databaseURL: 'https://gamebrary-8c736.firebaseio.com',
|
|
|
|
projectId: 'gamebrary-8c736',
|
|
|
|
storageBucket: 'gamebrary-8c736.appspot.com',
|
|
|
|
messagingSenderId: '324529217902',
|
2018-11-05 02:28:29 +00:00
|
|
|
});
|
|
|
|
|
2018-10-25 06:33:15 +00:00
|
|
|
const db = firebase.firestore();
|
|
|
|
|
2018-10-19 05:15:28 +00:00
|
|
|
export default {
|
2019-11-08 19:56:03 +00:00
|
|
|
name: 'App',
|
2018-10-19 05:15:28 +00:00
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
components: {
|
2021-01-10 19:55:45 +00:00
|
|
|
Dock,
|
2021-02-01 21:16:03 +00:00
|
|
|
GlobalModals,
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
2018-10-25 06:33:15 +00:00
|
|
|
|
2020-08-11 04:16:43 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
debugUserId: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
computed: {
|
2020-09-23 23:01:39 +00:00
|
|
|
...mapState(['user', 'wallpaperUrl', 'settings', 'sessionExpired']),
|
2020-10-14 00:38:35 +00:00
|
|
|
...mapGetters(['nightMode']),
|
2018-11-21 02:43:10 +00:00
|
|
|
|
2020-08-11 04:16:43 +00:00
|
|
|
userId() {
|
|
|
|
return this.debugUserId || this.user.uid;
|
|
|
|
},
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
dir() {
|
2020-10-23 00:06:56 +00:00
|
|
|
// TODO: find out all rtl languages and store in const
|
2019-11-08 19:56:03 +00:00
|
|
|
return this.settings && this.settings.language === 'ar'
|
|
|
|
? 'rtl'
|
|
|
|
: 'ltr';
|
|
|
|
},
|
2020-10-05 18:42:28 +00:00
|
|
|
|
|
|
|
isPublicBoard() {
|
|
|
|
return this.$route.meta && this.$route.meta.public;
|
|
|
|
},
|
2020-11-18 05:55:35 +00:00
|
|
|
|
|
|
|
isBoard() {
|
2021-01-06 21:42:33 +00:00
|
|
|
return ['public-board', 'board'].includes(this.$route.name);
|
2020-11-18 05:55:35 +00:00
|
|
|
},
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
|
2020-10-15 23:15:09 +00:00
|
|
|
async mounted() {
|
|
|
|
await this.$store.dispatch('GET_TWITCH_TOKEN');
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
this.init();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
init() {
|
2020-10-05 18:42:28 +00:00
|
|
|
if (this.isPublicBoard) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-08 19:56:03 +00:00
|
|
|
if (this.user) {
|
2020-09-09 23:36:04 +00:00
|
|
|
this.load();
|
2020-09-28 23:27:08 +00:00
|
|
|
} else if (this.$route.name !== 'auth') {
|
|
|
|
this.$router.replace({ name: 'auth' });
|
2019-11-08 19:56:03 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-28 23:27:08 +00:00
|
|
|
loadWallpapers() {
|
|
|
|
this.$store.dispatch('LOAD_WALLPAPERS')
|
|
|
|
.catch(() => {
|
2020-12-10 05:26:57 +00:00
|
|
|
this.$bvToast.toast('There was an error loading wallpapers', { variant: 'danger' });
|
2020-09-28 23:27:08 +00:00
|
|
|
});
|
|
|
|
},
|
2019-11-08 19:56:03 +00:00
|
|
|
|
2020-09-09 23:36:04 +00:00
|
|
|
load() {
|
2020-09-28 23:30:49 +00:00
|
|
|
// TODO: move logic to actions
|
2020-09-09 23:36:04 +00:00
|
|
|
this.$store.dispatch('LOAD_RELEASES')
|
|
|
|
.then((releases) => {
|
|
|
|
const [latestRelease] = releases;
|
|
|
|
|
|
|
|
const latestReleaseVersion = latestRelease && latestRelease.tag_name;
|
|
|
|
|
|
|
|
const lastReleaseSeenByUser = (this.settings && this.settings.release) || null;
|
|
|
|
|
2020-09-09 23:44:31 +00:00
|
|
|
if (latestReleaseVersion !== lastReleaseSeenByUser) {
|
2020-09-09 23:36:04 +00:00
|
|
|
this.$store.commit('SET_NOTIFICATION', true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-08-28 21:57:28 +00:00
|
|
|
this.loadWallpapers();
|
2020-09-28 23:30:49 +00:00
|
|
|
// TODO: remove onSnapshot? May get costly $$$
|
2019-12-18 23:03:57 +00:00
|
|
|
// TODO: track progresses as well
|
2019-11-08 19:56:03 +00:00
|
|
|
|
2019-12-03 18:26:35 +00:00
|
|
|
// TODO: move to actions
|
2020-08-11 04:16:43 +00:00
|
|
|
db.collection('settings').doc(this.userId)
|
2019-11-08 19:56:03 +00:00
|
|
|
.onSnapshot((doc) => {
|
|
|
|
if (doc.exists) {
|
|
|
|
const settings = doc.data();
|
|
|
|
|
|
|
|
this.$store.commit('SET_SETTINGS', settings);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-03 18:26:35 +00:00
|
|
|
// TODO: move to actions
|
2020-08-11 04:16:43 +00:00
|
|
|
db.collection('tags').doc(this.userId)
|
2019-11-08 19:56:03 +00:00
|
|
|
.onSnapshot((doc) => {
|
|
|
|
if (doc.exists) {
|
|
|
|
const tags = doc.data();
|
|
|
|
|
|
|
|
this.$store.commit('SET_TAGS', tags);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-03 18:26:35 +00:00
|
|
|
// TODO: move to actions
|
2020-08-11 04:16:43 +00:00
|
|
|
db.collection('notes').doc(this.userId)
|
2019-11-08 19:56:03 +00:00
|
|
|
.onSnapshot((doc) => {
|
|
|
|
if (doc.exists) {
|
|
|
|
const notes = doc.data();
|
|
|
|
|
|
|
|
this.$store.commit('SET_NOTES', notes);
|
|
|
|
}
|
|
|
|
});
|
2019-12-17 05:05:35 +00:00
|
|
|
|
|
|
|
// TODO: move to actions
|
2020-08-11 04:16:43 +00:00
|
|
|
db.collection('progresses').doc(this.userId)
|
2019-12-17 05:05:35 +00:00
|
|
|
.onSnapshot((doc) => {
|
|
|
|
if (doc.exists) {
|
|
|
|
const progresses = doc.data();
|
|
|
|
|
|
|
|
this.$store.commit('SET_PROGRESSES', progresses);
|
|
|
|
}
|
|
|
|
});
|
2019-11-08 19:56:03 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 05:15:28 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss">
|
2020-08-25 23:41:57 +00:00
|
|
|
@import "~styles/styles";
|
2018-10-19 05:15:28 +00:00
|
|
|
</style>
|
2019-02-15 22:58:32 +00:00
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
2020-09-26 00:09:20 +00:00
|
|
|
main {
|
|
|
|
height: 100vh;
|
|
|
|
overflow-y: auto;
|
2020-09-28 23:27:08 +00:00
|
|
|
|
|
|
|
&.authorizing {
|
|
|
|
width: 100%;
|
|
|
|
left: 0;
|
|
|
|
}
|
2020-11-18 05:55:35 +00:00
|
|
|
|
|
|
|
&.offset {
|
2020-11-21 06:34:15 +00:00
|
|
|
padding-left: 55px;
|
2020-11-18 05:55:35 +00:00
|
|
|
}
|
2019-11-08 20:34:06 +00:00
|
|
|
}
|
2019-02-15 22:58:32 +00:00
|
|
|
</style>
|