Skip to content

Commit 95c3b47

Browse files
author
David Žaba
committed
fix: TypeError When Deleting Nested Data
1 parent a7a3aa7 commit 95c3b47

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

dist/index.cjs.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var pathToProp = _interopDefault(require('path-to-prop'));
1717
var compareAnything = require('compare-anything');
1818
var findAndReplaceAnything = require('find-and-replace-anything');
1919
var filter = _interopDefault(require('filter-anything'));
20+
var firebase$2 = _interopDefault(require('firebase/compat'));
2021

2122
/*! *****************************************************************************
2223
Copyright (c) Microsoft Corporation.
@@ -2986,7 +2987,7 @@ function pluginActions (firestoreConfig) {
29862987
.set(initialDocPrepared)
29872988
.then(function () {
29882989
if (state._conf.logging) {
2989-
var message = 'Initial doc succesfully inserted';
2990+
var message = 'Initial doc successfully inserted';
29902991
console.log("%c [vuex-easy-firestore] " + message + "; for Firestore PATH: " + getters.firestorePathComplete + " [" + state._conf.firestorePath + "]", 'color: SeaGreen');
29912992
}
29922993
resolve(true);
@@ -3926,7 +3927,7 @@ function pluginActions (firestoreConfig) {
39263927
return storeUpdateFn(ids);
39273928
},
39283929
_stopPatching: function (_a) {
3929-
var state = _a.state, commit = _a.commit;
3930+
var state = _a.state;
39303931
if (state._sync.stopPatchingTimeout) {
39313932
clearTimeout(state._sync.stopPatchingTimeout);
39323933
}
@@ -3935,7 +3936,7 @@ function pluginActions (firestoreConfig) {
39353936
}, 300);
39363937
},
39373938
_startPatching: function (_a) {
3938-
var state = _a.state, commit = _a.commit;
3939+
var state = _a.state;
39393940
if (state._sync.stopPatchingTimeout) {
39403941
clearTimeout(state._sync.stopPatchingTimeout);
39413942
}
@@ -3944,6 +3945,7 @@ function pluginActions (firestoreConfig) {
39443945
};
39453946
}
39463947

3948+
var FieldValue = firebase$2.firestore.FieldValue;
39473949
/**
39483950
* A function returning the getters object
39493951
*
@@ -4062,11 +4064,11 @@ function pluginGetters (firebase) {
40624064
id = getters.docModeId;
40634065
cleanedPath = path;
40644066
}
4065-
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete();
4067+
cleanedPatchData[cleanedPath] = FieldValue.delete();
40664068
cleanedPatchData.id = id;
40674069
return _a = {}, _a[id] = cleanedPatchData, _a;
40684070
}; },
4069-
prepareForInsert: function (state, getters, rootState, rootGetters) { return function (items) {
4071+
prepareForInsert: function (state, getters) { return function (items) {
40704072
if (items === void 0) { items = []; }
40714073
// add fillable and guard defaults
40724074
return items.reduce(function (carry, item) {

dist/index.esm.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import pathToProp from 'path-to-prop';
1010
import { compareObjectProps } from 'compare-anything';
1111
import { findAndReplace, findAndReplaceIf } from 'find-and-replace-anything';
1212
import filter from 'filter-anything';
13+
import firebase$2 from 'firebase/compat';
1314

1415
/*! *****************************************************************************
1516
Copyright (c) Microsoft Corporation.
@@ -2979,7 +2980,7 @@ function pluginActions (firestoreConfig) {
29792980
.set(initialDocPrepared)
29802981
.then(function () {
29812982
if (state._conf.logging) {
2982-
var message = 'Initial doc succesfully inserted';
2983+
var message = 'Initial doc successfully inserted';
29832984
console.log("%c [vuex-easy-firestore] " + message + "; for Firestore PATH: " + getters.firestorePathComplete + " [" + state._conf.firestorePath + "]", 'color: SeaGreen');
29842985
}
29852986
resolve(true);
@@ -3919,7 +3920,7 @@ function pluginActions (firestoreConfig) {
39193920
return storeUpdateFn(ids);
39203921
},
39213922
_stopPatching: function (_a) {
3922-
var state = _a.state, commit = _a.commit;
3923+
var state = _a.state;
39233924
if (state._sync.stopPatchingTimeout) {
39243925
clearTimeout(state._sync.stopPatchingTimeout);
39253926
}
@@ -3928,7 +3929,7 @@ function pluginActions (firestoreConfig) {
39283929
}, 300);
39293930
},
39303931
_startPatching: function (_a) {
3931-
var state = _a.state, commit = _a.commit;
3932+
var state = _a.state;
39323933
if (state._sync.stopPatchingTimeout) {
39333934
clearTimeout(state._sync.stopPatchingTimeout);
39343935
}
@@ -3937,6 +3938,7 @@ function pluginActions (firestoreConfig) {
39373938
};
39383939
}
39393940

3941+
var FieldValue = firebase$2.firestore.FieldValue;
39403942
/**
39413943
* A function returning the getters object
39423944
*
@@ -4055,11 +4057,11 @@ function pluginGetters (firebase) {
40554057
id = getters.docModeId;
40564058
cleanedPath = path;
40574059
}
4058-
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete();
4060+
cleanedPatchData[cleanedPath] = FieldValue.delete();
40594061
cleanedPatchData.id = id;
40604062
return _a = {}, _a[id] = cleanedPatchData, _a;
40614063
}; },
4062-
prepareForInsert: function (state, getters, rootState, rootGetters) { return function (items) {
4064+
prepareForInsert: function (state, getters) { return function (items) {
40634065
if (items === void 0) { items = []; }
40644066
// add fillable and guard defaults
40654067
return items.reduce(function (carry, item) {

src/module/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default function (firestoreConfig: FirestoreConfig): AnyObject {
180180
.set(initialDocPrepared)
181181
.then(() => {
182182
if (state._conf.logging) {
183-
const message = 'Initial doc succesfully inserted'
183+
const message = 'Initial doc successfully inserted'
184184
console.log(
185185
`%c [vuex-easy-firestore] ${message}; for Firestore PATH: ${getters.firestorePathComplete} [${state._conf.firestorePath}]`,
186186
'color: SeaGreen'
@@ -1150,15 +1150,15 @@ export default function (firestoreConfig: FirestoreConfig): AnyObject {
11501150
}
11511151
return storeUpdateFn(ids)
11521152
},
1153-
_stopPatching ({ state, commit }) {
1153+
_stopPatching ({ state }) {
11541154
if (state._sync.stopPatchingTimeout) {
11551155
clearTimeout(state._sync.stopPatchingTimeout)
11561156
}
11571157
state._sync.stopPatchingTimeout = setTimeout(_ => {
11581158
state._sync.patching = false
11591159
}, 300)
11601160
},
1161-
_startPatching ({ state, commit }) {
1161+
_startPatching ({ state }) {
11621162
if (state._sync.stopPatchingTimeout) {
11631163
clearTimeout(state._sync.stopPatchingTimeout)
11641164
}

src/module/getters.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { getPathVarMatches } from '../utils/apiHelpers'
77
import setDefaultValues from '../utils/setDefaultValues'
88
import { AnyObject } from '../declarations'
99
import error from './errors'
10+
import firebase from 'firebase/compat'
11+
import FieldValue = firebase.firestore.FieldValue;
1012

1113
export type IPluginGetters = {
1214
firestorePathComplete: (state: any, getters?: any, rootState?: any, rootGetters?: any) => string
@@ -145,11 +147,13 @@ export default function (firebase: any): AnyObject {
145147
id = getters.docModeId
146148
cleanedPath = path
147149
}
148-
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete()
150+
151+
cleanedPatchData[cleanedPath] = FieldValue.delete()
149152
cleanedPatchData.id = id
153+
150154
return { [id]: cleanedPatchData }
151155
},
152-
prepareForInsert: (state, getters, rootState, rootGetters) => (items = []) => {
156+
prepareForInsert: (state, getters) => (items = []) => {
153157
// add fillable and guard defaults
154158
return items.reduce((carry, item) => {
155159
// set default fields

test/helpers/index.cjs.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var pathToProp = _interopDefault(require('path-to-prop'));
1818
var compareAnything = require('compare-anything');
1919
var findAndReplaceAnything = require('find-and-replace-anything');
2020
var filter = _interopDefault(require('filter-anything'));
21+
var firebase$2 = _interopDefault(require('firebase/compat'));
2122

2223
function initialState() {
2324
return {
@@ -3505,7 +3506,7 @@ function pluginActions (firestoreConfig) {
35053506
.set(initialDocPrepared)
35063507
.then(function () {
35073508
if (state._conf.logging) {
3508-
var message = 'Initial doc succesfully inserted';
3509+
var message = 'Initial doc successfully inserted';
35093510
console.log("%c [vuex-easy-firestore] " + message + "; for Firestore PATH: " + getters.firestorePathComplete + " [" + state._conf.firestorePath + "]", 'color: SeaGreen');
35103511
}
35113512
resolve(true);
@@ -4445,7 +4446,7 @@ function pluginActions (firestoreConfig) {
44454446
return storeUpdateFn(ids);
44464447
},
44474448
_stopPatching: function (_a) {
4448-
var state = _a.state, commit = _a.commit;
4449+
var state = _a.state;
44494450
if (state._sync.stopPatchingTimeout) {
44504451
clearTimeout(state._sync.stopPatchingTimeout);
44514452
}
@@ -4454,7 +4455,7 @@ function pluginActions (firestoreConfig) {
44544455
}, 300);
44554456
},
44564457
_startPatching: function (_a) {
4457-
var state = _a.state, commit = _a.commit;
4458+
var state = _a.state;
44584459
if (state._sync.stopPatchingTimeout) {
44594460
clearTimeout(state._sync.stopPatchingTimeout);
44604461
}
@@ -4463,6 +4464,7 @@ function pluginActions (firestoreConfig) {
44634464
};
44644465
}
44654466

4467+
var FieldValue = firebase$2.firestore.FieldValue;
44664468
/**
44674469
* A function returning the getters object
44684470
*
@@ -4581,11 +4583,11 @@ function pluginGetters (firebase) {
45814583
id = getters.docModeId;
45824584
cleanedPath = path;
45834585
}
4584-
cleanedPatchData[cleanedPath] = firebase.firestore.FieldValue.delete();
4586+
cleanedPatchData[cleanedPath] = FieldValue.delete();
45854587
cleanedPatchData.id = id;
45864588
return _a = {}, _a[id] = cleanedPatchData, _a;
45874589
}; },
4588-
prepareForInsert: function (state, getters, rootState, rootGetters) { return function (items) {
4590+
prepareForInsert: function (state, getters) { return function (items) {
45894591
if (items === void 0) { items = []; }
45904592
// add fillable and guard defaults
45914593
return items.reduce(function (carry, item) {

0 commit comments

Comments
 (0)