Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hiporox committed Jul 12, 2024
1 parent c437df5 commit b4ff9fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
17 changes: 12 additions & 5 deletions src/common/data/stores/app/homebase/homebaseStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 11 additions & 7 deletions src/common/data/stores/app/space/spaceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b4ff9fd

Please sign in to comment.