Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TypeError When Deleting Nested Data #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dist/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var pathToProp = _interopDefault(require('path-to-prop'));
var compareAnything = require('compare-anything');
var findAndReplaceAnything = require('find-and-replace-anything');
var filter = _interopDefault(require('filter-anything'));
var firebase$2 = _interopDefault(require('firebase/compat'));

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Expand Down Expand Up @@ -2986,7 +2987,7 @@ function pluginActions (firestoreConfig) {
.set(initialDocPrepared)
.then(function () {
if (state._conf.logging) {
var message = 'Initial doc succesfully inserted';
var message = 'Initial doc successfully inserted';
console.log("%c [vuex-easy-firestore] " + message + "; for Firestore PATH: " + getters.firestorePathComplete + " [" + state._conf.firestorePath + "]", 'color: SeaGreen');
}
resolve(true);
Expand Down Expand Up @@ -3926,7 +3927,7 @@ function pluginActions (firestoreConfig) {
return storeUpdateFn(ids);
},
_stopPatching: function (_a) {
var state = _a.state, commit = _a.commit;
var state = _a.state;
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout);
}
Expand All @@ -3935,7 +3936,7 @@ function pluginActions (firestoreConfig) {
}, 300);
},
_startPatching: function (_a) {
var state = _a.state, commit = _a.commit;
var state = _a.state;
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout);
}
Expand All @@ -3944,6 +3945,7 @@ function pluginActions (firestoreConfig) {
};
}

var FieldValue = firebase$2.firestore.FieldValue;
/**
* A function returning the getters object
*
Expand Down Expand Up @@ -4062,11 +4064,11 @@ function pluginGetters (firebase) {
id = getters.docModeId;
cleanedPath = path;
}
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete();
cleanedPatchData[cleanedPath] = FieldValue.delete();
cleanedPatchData.id = id;
return _a = {}, _a[id] = cleanedPatchData, _a;
}; },
prepareForInsert: function (state, getters, rootState, rootGetters) { return function (items) {
prepareForInsert: function (state, getters) { return function (items) {
if (items === void 0) { items = []; }
// add fillable and guard defaults
return items.reduce(function (carry, item) {
Expand Down
12 changes: 7 additions & 5 deletions dist/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import pathToProp from 'path-to-prop';
import { compareObjectProps } from 'compare-anything';
import { findAndReplace, findAndReplaceIf } from 'find-and-replace-anything';
import filter from 'filter-anything';
import firebase$2 from 'firebase/compat';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Expand Down Expand Up @@ -2979,7 +2980,7 @@ function pluginActions (firestoreConfig) {
.set(initialDocPrepared)
.then(function () {
if (state._conf.logging) {
var message = 'Initial doc succesfully inserted';
var message = 'Initial doc successfully inserted';
console.log("%c [vuex-easy-firestore] " + message + "; for Firestore PATH: " + getters.firestorePathComplete + " [" + state._conf.firestorePath + "]", 'color: SeaGreen');
}
resolve(true);
Expand Down Expand Up @@ -3919,7 +3920,7 @@ function pluginActions (firestoreConfig) {
return storeUpdateFn(ids);
},
_stopPatching: function (_a) {
var state = _a.state, commit = _a.commit;
var state = _a.state;
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout);
}
Expand All @@ -3928,7 +3929,7 @@ function pluginActions (firestoreConfig) {
}, 300);
},
_startPatching: function (_a) {
var state = _a.state, commit = _a.commit;
var state = _a.state;
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout);
}
Expand All @@ -3937,6 +3938,7 @@ function pluginActions (firestoreConfig) {
};
}

var FieldValue = firebase$2.firestore.FieldValue;
/**
* A function returning the getters object
*
Expand Down Expand Up @@ -4055,11 +4057,11 @@ function pluginGetters (firebase) {
id = getters.docModeId;
cleanedPath = path;
}
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete();
cleanedPatchData[cleanedPath] = FieldValue.delete();
cleanedPatchData.id = id;
return _a = {}, _a[id] = cleanedPatchData, _a;
}; },
prepareForInsert: function (state, getters, rootState, rootGetters) { return function (items) {
prepareForInsert: function (state, getters) { return function (items) {
if (items === void 0) { items = []; }
// add fillable and guard defaults
return items.reduce(function (carry, item) {
Expand Down
6 changes: 3 additions & 3 deletions src/module/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default function (firestoreConfig: FirestoreConfig): AnyObject {
.set(initialDocPrepared)
.then(() => {
if (state._conf.logging) {
const message = 'Initial doc succesfully inserted'
const message = 'Initial doc successfully inserted'
console.log(
`%c [vuex-easy-firestore] ${message}; for Firestore PATH: ${getters.firestorePathComplete} [${state._conf.firestorePath}]`,
'color: SeaGreen'
Expand Down Expand Up @@ -1150,15 +1150,15 @@ export default function (firestoreConfig: FirestoreConfig): AnyObject {
}
return storeUpdateFn(ids)
},
_stopPatching ({ state, commit }) {
_stopPatching ({ state }) {
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout)
}
state._sync.stopPatchingTimeout = setTimeout(_ => {
state._sync.patching = false
}, 300)
},
_startPatching ({ state, commit }) {
_startPatching ({ state }) {
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout)
}
Expand Down
8 changes: 6 additions & 2 deletions src/module/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { getPathVarMatches } from '../utils/apiHelpers'
import setDefaultValues from '../utils/setDefaultValues'
import { AnyObject } from '../declarations'
import error from './errors'
import firebase from 'firebase/compat'
import FieldValue = firebase.firestore.FieldValue;

export type IPluginGetters = {
firestorePathComplete: (state: any, getters?: any, rootState?: any, rootGetters?: any) => string
Expand Down Expand Up @@ -145,11 +147,13 @@ export default function (firebase: any): AnyObject {
id = getters.docModeId
cleanedPath = path
}
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete()

cleanedPatchData[cleanedPath] = FieldValue.delete()
cleanedPatchData.id = id

return { [id]: cleanedPatchData }
},
prepareForInsert: (state, getters, rootState, rootGetters) => (items = []) => {
prepareForInsert: (state, getters) => (items = []) => {
// add fillable and guard defaults
return items.reduce((carry, item) => {
// set default fields
Expand Down
12 changes: 7 additions & 5 deletions test/helpers/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var pathToProp = _interopDefault(require('path-to-prop'));
var compareAnything = require('compare-anything');
var findAndReplaceAnything = require('find-and-replace-anything');
var filter = _interopDefault(require('filter-anything'));
var firebase$2 = _interopDefault(require('firebase/compat'));

function initialState() {
return {
Expand Down Expand Up @@ -3505,7 +3506,7 @@ function pluginActions (firestoreConfig) {
.set(initialDocPrepared)
.then(function () {
if (state._conf.logging) {
var message = 'Initial doc succesfully inserted';
var message = 'Initial doc successfully inserted';
console.log("%c [vuex-easy-firestore] " + message + "; for Firestore PATH: " + getters.firestorePathComplete + " [" + state._conf.firestorePath + "]", 'color: SeaGreen');
}
resolve(true);
Expand Down Expand Up @@ -4445,7 +4446,7 @@ function pluginActions (firestoreConfig) {
return storeUpdateFn(ids);
},
_stopPatching: function (_a) {
var state = _a.state, commit = _a.commit;
var state = _a.state;
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout);
}
Expand All @@ -4454,7 +4455,7 @@ function pluginActions (firestoreConfig) {
}, 300);
},
_startPatching: function (_a) {
var state = _a.state, commit = _a.commit;
var state = _a.state;
if (state._sync.stopPatchingTimeout) {
clearTimeout(state._sync.stopPatchingTimeout);
}
Expand All @@ -4463,6 +4464,7 @@ function pluginActions (firestoreConfig) {
};
}

var FieldValue = firebase$2.firestore.FieldValue;
/**
* A function returning the getters object
*
Expand Down Expand Up @@ -4581,11 +4583,11 @@ function pluginGetters (firebase) {
id = getters.docModeId;
cleanedPath = path;
}
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete();
cleanedPatchData[cleanedPath] = FieldValue.delete();
cleanedPatchData.id = id;
return _a = {}, _a[id] = cleanedPatchData, _a;
}; },
prepareForInsert: function (state, getters, rootState, rootGetters) { return function (items) {
prepareForInsert: function (state, getters) { return function (items) {
if (items === void 0) { items = []; }
// add fillable and guard defaults
return items.reduce(function (carry, item) {
Expand Down