From e1fd8631a215869d9c2916b2a362710c9367d62e Mon Sep 17 00:00:00 2001 From: Magnus Rand Date: Wed, 22 Sep 2021 11:03:13 +0200 Subject: [PATCH 1/2] Fix app not redirecting to root on page that doesnt exist --- src/settings/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/index.ts b/src/settings/index.ts index 022b5f01e..1e64e2b12 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -95,7 +95,7 @@ export function useSettings(): [Settings | null, Setter] { if (id) { return onSnapshot(getSettings(id), (document: any) => { - if (!document.exists) { + if (!document.exists()) { window.location.pathname = '/' return } From 33e5865b034f1b308f086933a384fff748f2372d Mon Sep 17 00:00:00 2001 From: Magnus Rand Date: Wed, 22 Sep 2021 11:17:13 +0200 Subject: [PATCH 2/2] Refactor variable to comply with firebase documentation (https://firebase.google.com/docs/firestore/query-data/get-data#get_a_document) --- src/settings/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/settings/index.ts b/src/settings/index.ts index 1e64e2b12..55ed1228b 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -94,13 +94,13 @@ export function useSettings(): [Settings | null, Setter] { } if (id) { - return onSnapshot(getSettings(id), (document: any) => { - if (!document.exists()) { + return onSnapshot(getSettings(id), (documentSnapshot: any) => { + if (!documentSnapshot.exists()) { window.location.pathname = '/' return } - const data = document.data() as Settings + const data = documentSnapshot.data() as Settings const settingsWithDefaults: Settings = { ...DEFAULT_SETTINGS,