Added todos for firebase calls

This commit is contained in:
Roman Cervantes 2019-09-23 13:03:30 -07:00
parent 640288fcf1
commit 52336b2388
10 changed files with 26 additions and 1 deletions

View file

@ -158,6 +158,7 @@ export default {
saveSettings: debounce(
// eslint-disable-next-line
function(settings) {
// TOOD: move to actions
db.collection('settings').doc(this.user.uid).set(settings, { merge: true })
.then(() => {
this.$store.commit('SET_SETTINGS', settings);
@ -171,6 +172,7 @@ export default {
saveTags(tags, force) {
if (tags) {
// TOOD: move to actions
db.collection('tags').doc(this.user.uid).set(tags, { merge: !force })
.then(() => {
this.$bus.$emit('TOAST', { message: 'Tags updated' });
@ -184,6 +186,7 @@ export default {
saveNotes(notes, force) {
if (notes) {
// TOOD: move to actions
db.collection('notes').doc(this.user.uid).set(notes, { merge: !force })
.then(() => {
this.$bus.$emit('TOAST', { message: 'Notes updated' });
@ -196,6 +199,7 @@ export default {
},
syncData() {
// TOOD: move to actions
db.collection('lists').doc(this.user.uid)
.onSnapshot((doc) => {
if (doc.exists) {
@ -205,6 +209,7 @@ export default {
});
// TOOD: move to actions
db.collection('settings').doc(this.user.uid)
.onSnapshot((doc) => {
if (doc.exists) {
@ -214,6 +219,7 @@ export default {
}
});
// TOOD: move to actions
db.collection('tags').doc(this.user.uid)
.onSnapshot((doc) => {
if (doc.exists) {
@ -223,6 +229,7 @@ export default {
}
});
// TOOD: move to actions
db.collection('notes').doc(this.user.uid)
.onSnapshot((doc) => {
if (doc.exists) {
@ -233,7 +240,7 @@ export default {
});
},
init(user) {
initUser(user) {
this.$store.commit('SET_USER', user);
this.loadSettings();
this.loadTags();
@ -242,6 +249,7 @@ export default {
},
loadSettings() {
// TOOD: move to actions
const docRef = db.collection('settings').doc(this.user.uid);
docRef.get().then((doc) => {
@ -257,6 +265,7 @@ export default {
},
loadLists() {
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).get()
.then((doc) => {
if (doc.exists) {
@ -273,6 +282,7 @@ export default {
},
loadTags() {
// TOOD: move to actions
db.collection('tags').doc(this.user.uid).get()
.then((doc) => {
if (doc.exists) {
@ -287,6 +297,7 @@ export default {
},
initList() {
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set({}, { merge: true })
.then(() => {
this.loadLists();
@ -298,6 +309,7 @@ export default {
},
initSettings() {
// TOOD: move to actions
db.collection('settings').doc(this.user.uid).set({}, { merge: true })
.then(() => {
this.loadSettings();

View file

@ -101,6 +101,7 @@ export default {
eventValue: data,
});
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
this.$bus.$emit('TOAST', {
@ -127,6 +128,7 @@ export default {
this.$store.commit('REMOVE_GAME', data);
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
this.$bus.$emit('TOAST', {

View file

@ -248,6 +248,7 @@ export default {
const message = toastMessage || 'List saved';
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
this.$bus.$emit('TOAST', { message });

View file

@ -196,6 +196,8 @@ export default {
deleteList() {
this.$store.commit('REMOVE_LIST', this.activeListIndex);
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
this.$bus.$emit('TOAST', { message: 'List deleted' });

View file

@ -63,8 +63,11 @@ export default {
deleteAccount() {
const db = firebase.firestore();
// TOOD: move to actions
db.collection('settings').doc(this.user.uid).delete()
.then(() => {
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).delete()
.then(() => {
this.$bus.$emit('TOAST', { message: 'Account deleted' });

View file

@ -134,6 +134,7 @@ export default {
const db = firebase.firestore();
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: false })
.then(() => {
this.$router.push({ name: 'platforms' });

View file

@ -129,6 +129,7 @@ export default {
const db = firebase.firestore();
// TOOD: move to actions
db.collection('settings').doc(this.user.uid).set(settings)
.then(() => {
this.$store.commit('SET_SETTINGS', settings);

View file

@ -207,6 +207,7 @@ export default {
},
updateLists(force) {
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: !force })
.catch(() => {
this.$bus.$emit('TOAST', { message: 'Authentication error', type: 'error' });

View file

@ -174,6 +174,7 @@ export default {
this.$store.commit('REMOVE_GAME', data);
// TOOD: move to actions
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
this.$bus.$emit('TOAST', {

View file

@ -66,6 +66,7 @@ export default {
const message = this.$t('errors.loading');
// TOOD: move to actions
db.collection('lists').doc(id).get()
.then((doc) => {
if (doc.exists) {