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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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