sveltedfire 0.1.13 → 0.1.15

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.
@@ -3,5 +3,6 @@ export type AuthSig = {
3
3
  currentUser: User | null;
4
4
  signInWithGoogle: any;
5
5
  signOut: any;
6
+ initialized: boolean;
6
7
  [k: string]: any;
7
8
  };
@@ -1,11 +1,11 @@
1
1
  <script lang="ts">
2
2
  const { children } = $props()
3
3
  import { getContext } from 'svelte';
4
- import { AuthSig } from '../auth/AuthSig.js';
4
+ import { type AuthSig } from '../auth/AuthSig.js';
5
5
 
6
6
  let fullAuth = getContext<AuthSig>('sveltedAuth')
7
7
  </script>
8
8
 
9
- {#if fullAuth!.currentUser}
9
+ {#if fullAuth.initialized && fullAuth!.currentUser}
10
10
  {@render children()}
11
11
  {/if}
@@ -6,6 +6,6 @@
6
6
  let fullAuth = getContext<AuthSig>('sveltedAuth')
7
7
  </script>
8
8
 
9
- {#if fullAuth && !fullAuth!.currentUser}
9
+ {#if fullAuth && fullAuth.initialized && !fullAuth!.currentUser}
10
10
  {@render children()}
11
11
  {/if}
@@ -20,11 +20,13 @@
20
20
 
21
21
  let fullAuth = $state<AuthSig>({
22
22
  currentUser: null,
23
+ initialized: false,
23
24
  signOut,
24
25
  signInWithGoogle
25
26
  })
26
27
 
27
28
  auth.onAuthStateChanged(user => {
29
+ fullAuth.initialized = true
28
30
  fullAuth.currentUser = user
29
31
  Object.keys(additionalKeys).forEach((k: string) => {
30
32
  fullAuth[k] = rest[additionalKeys[k]](null, null)
@@ -55,7 +55,7 @@ export const handleForm = ({ collectionName, docId = null, docIdField = null, on
55
55
  const isLiteralObject = (a) => (!!a) && (a.constructor === Object);
56
56
  const cleanArrays = (obj) => {
57
57
  if (Array.isArray(obj)) {
58
- return obj.filter(k => k !== deleteField());
58
+ return obj.filter(k => JSON.stringify(k) !== JSON.stringify(deleteField())); // Raw comparison does not work
59
59
  }
60
60
  else {
61
61
  if (isLiteralObject(obj)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sveltedfire",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",