@edgedev/firebase 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.ts +6 -7
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  collection,
7
7
  addDoc,
8
8
  updateDoc,
9
- setDoc,
10
9
  doc,
11
10
  query,
12
11
  onSnapshot
@@ -29,10 +28,10 @@ const db = getFirestore(app);
29
28
  // Simple Store Items (add matching key per firebase collection)
30
29
  export const data = reactive({});
31
30
  export const unsubscibe = reactive({});
32
- export const user = ref(null);
31
+ export const user = ref({});
33
32
 
34
33
  // Composable to start snapshot listener and set unsubscribe function
35
- export const startSnapshot = (collectionPath: string) => {
34
+ export const startSnapshot = (collectionPath: string): void => {
36
35
  // This first "if" is to prevent multiple listeners on the same collection
37
36
  if (!(data[collectionPath] instanceof Function)) {
38
37
  const q = query(collection(db, collectionPath));
@@ -49,12 +48,12 @@ export const startSnapshot = (collectionPath: string) => {
49
48
  }
50
49
  };
51
50
 
52
- export const storeDoc = (collectionPath: string, item: object) => {
51
+ export const storeDoc = (collectionPath: string, item: object): void => {
53
52
  const cloneItem = JSON.parse(JSON.stringify(item));
54
53
  const current_time = new Date().getTime();
55
54
  cloneItem.last_updated = current_time;
56
- if (user) {
57
- cloneItem.uid = user.uid;
55
+ if (Object.keys(user).length > 0) {
56
+ cloneItem.uid = user["uid"];
58
57
  }
59
58
  if (!Object.prototype.hasOwnProperty.call(cloneItem, "doc_created_at")) {
60
59
  cloneItem.doc_created_at = current_time;
@@ -76,7 +75,7 @@ export const storeDoc = (collectionPath: string, item: object) => {
76
75
  };
77
76
 
78
77
  // Composable to stop snapshot listener
79
- export const stopSnapshot = (collectionPath: string) => {
78
+ export const stopSnapshot = (collectionPath: string): void => {
80
79
  if (unsubscibe[collectionPath] instanceof Function) {
81
80
  unsubscibe[collectionPath]();
82
81
  unsubscibe[collectionPath] = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Composables and stores for firebase",
5
5
  "main": "index.ts",
6
6
  "author": "Seth Fischer",