From 8037495aeaaae3870846331b4a10848f047e7036 Mon Sep 17 00:00:00 2001 From: "Fredrick W. Warren" Date: Mon, 15 Feb 2021 12:12:16 -0800 Subject: [PATCH] 24.02 Handle Write Errors --- src/store/store-tasks.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/store/store-tasks.js b/src/store/store-tasks.js index 94c4e3f..da617ab 100644 --- a/src/store/store-tasks.js +++ b/src/store/store-tasks.js @@ -1,6 +1,7 @@ import Vue from 'vue' import { uid } from 'quasar' import { firebaseDb, firebaseAuth } from 'boot/firebase' +import { showErrorMessage } from 'src/functions/function-show-error-message' const state = { tasks: { @@ -113,17 +114,29 @@ const actions = { fbAddTask ({ commit }, payload) { const userId = firebaseAuth.currentUser.uid const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id) - taskRef.set(payload.task) + taskRef.set(payload.task, error => { + if (error) { + showErrorMessage(error.message) + } + }) }, fbUpdateTask ({ commit }, payload) { const userId = firebaseAuth.currentUser.uid const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id) - taskRef.update(payload.updates) + taskRef.update(payload.updates, error => { + if (error) { + showErrorMessage(error.message) + } + }) }, fbDeleteTask ({ commit }, taskId) { const userId = firebaseAuth.currentUser.uid const taskRef = firebaseDb.ref('tasks/' + userId + '/' + taskId) - taskRef.remove() + taskRef.remove(error => { + if (error) { + showErrorMessage(error.message) + } + }) } }