Skip to content

Commit

Permalink
release(v2.1.1): fixed FireBase DB rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Frey authored and Daniel Frey committed Nov 1, 2021
1 parent 949a2f9 commit 7ce1390
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,jsx,tsx,ts}]
charset = utf-8
indent_style = space
indent_size = 2

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recipe-app",
"version": "2.1.0",
"version": "2.1.1",
"private": true,
"scripts": {
"serve": "npm outdated & vue-cli-service serve --host localhost",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Recipe/Cards/RecipeCard.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<v-card
color="#F9F5F3"
style="cursor: pointer; position: relative;"
style="cursor: pointer; position: relative"
:loading="isLoading || isCardLoading"
:disabled="isLoading || isCardLoading"
@dblclick="onLike(recipe)"
Expand Down
28 changes: 14 additions & 14 deletions src/store/recipes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ export default {
},

async addLikeCount({ commit }, payload) {
const recipe = { ...payload };
const updates = {};
try {
recipe.likes += 1;
recipe.image = 0;
updates[
`recipes/${payload.id}/likes`
] = firebase.database.ServerValue.increment(1);

// Update props on the DB
await firebase
firebase
.database()
.ref("recipes")
.child(payload.id)
.update(recipe);
.ref()
.update(updates);

commit("addLikeCount", payload);
} catch (err) {
Expand All @@ -284,17 +284,17 @@ export default {
},

async dislikeCount({ commit }, payload) {
const recipe = { ...payload };
const updates = {};
try {
recipe.likes -= 1;
recipe.image = 0;
updates[
`recipes/${payload.id}/likes`
] = firebase.database.ServerValue.increment(-1);

// Update props on the DB
await firebase
firebase
.database()
.ref("recipes")
.child(payload.id)
.update(recipe);
.ref()
.update(updates);
commit("dislikeCount", payload);
} catch (err) {
commit("setAlert", { message: err.message, type: "error" });
Expand Down

0 comments on commit 7ce1390

Please sign in to comment.