From b4ff9fd7640cf9281b08b1baa5f879d416746a0e Mon Sep 17 00:00:00 2001 From: Julian Early Date: Fri, 12 Jul 2024 13:20:54 -0700 Subject: [PATCH] fix: address comments --- .../data/stores/app/homebase/homebaseStore.ts | 17 ++++++++++++----- src/common/data/stores/app/space/spaceStore.ts | 18 +++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/common/data/stores/app/homebase/homebaseStore.ts b/src/common/data/stores/app/homebase/homebaseStore.ts index 0d687f51..7f160d79 100644 --- a/src/common/data/stores/app/homebase/homebaseStore.ts +++ b/src/common/data/stores/app/homebase/homebaseStore.ts @@ -4,7 +4,7 @@ import axios from "axios"; import { createClient } from "../../../database/supabase/clients/component"; import { homebasePath } from "@/constants/supabase"; import { SignedFile } from "@/common/lib/signedFiles"; -import { cloneDeep, debounce, isArray, mergeWith } from "lodash"; +import { cloneDeep, debounce, isArray, isUndefined, mergeWith } from "lodash"; import stringify from "fast-json-stable-stringify"; import axiosBackend from "../../../api/backend"; import { @@ -62,10 +62,17 @@ export const createHomeBaseStoreFunc = ( ) as SpaceConfig; const currentHomebase = get().homebase.homebaseConfig; if ( - spaceConfig.timestamp && - currentHomebase && - currentHomebase.timestamp && - moment(spaceConfig.timestamp).isAfter(moment(currentHomebase.timestamp)) + (spaceConfig && + spaceConfig.timestamp && + currentHomebase && + currentHomebase.timestamp && + moment(spaceConfig.timestamp).isAfter( + moment(currentHomebase.timestamp), + )) || + (spaceConfig && + isUndefined(spaceConfig.timestamp) && + currentHomebase && + currentHomebase.timestamp) ) { console.debug("local homebase config is more recent"); return cloneDeep(currentHomebase); diff --git a/src/common/data/stores/app/space/spaceStore.ts b/src/common/data/stores/app/space/spaceStore.ts index ce48e5d3..f6a71c00 100644 --- a/src/common/data/stores/app/space/spaceStore.ts +++ b/src/common/data/stores/app/space/spaceStore.ts @@ -131,13 +131,17 @@ export const createSpaceStoreFunc = ( ) as DatabaseWritableSpaceConfig; const currentLocalCopy = get().space.localSpaces[spaceId]; if ( - spaceConfig && - spaceConfig.timestamp && - currentLocalCopy && - currentLocalCopy.timestamp && - moment(currentLocalCopy.timestamp).isAfter( - moment(spaceConfig.timestamp), - ) + (spaceConfig && + spaceConfig.timestamp && + currentLocalCopy && + currentLocalCopy.timestamp && + moment(currentLocalCopy.timestamp).isAfter( + moment(spaceConfig.timestamp), + )) || + (spaceConfig && + isUndefined(spaceConfig.timestamp) && + currentLocalCopy && + currentLocalCopy.timestamp) ) { console.debug(`local copy of space ${spaceId} config is more recent`); return;