Merge pull request #1530 from rowyio/develop

Develop
This commit is contained in:
Shams
2024-01-26 02:52:10 -08:00
committed by GitHub
4 changed files with 25 additions and 18 deletions

View File

@@ -101,7 +101,7 @@ https://user-images.githubusercontent.com/307298/157185793-f67511cd-7b7b-4229-95
Set up Rowy on your Google Cloud Platform project with this easy deploy button.
Your data and cloud functions stay on your own Firestore/GCP and is managed via
a cloud run instance that operates exclusively on your GCP project. So we do do
a cloud run instance that operates exclusively on your GCP project. So we do
not access or store any of your data on Rowy.
[<img width="200" alt="Guided quick start button" src="https://user-images.githubusercontent.com/307298/185548050-e9208fb6-fe53-4c84-bbfa-53c08e03c15f.png">](https://rowy.app/)

View File

@@ -386,9 +386,7 @@ export const updateFieldAtom = atom(
);
if (!row) throw new Error("Could not find row");
const isLocalRow =
fieldName.startsWith("_rowy_formulaValue_") ||
Boolean(find(tableRowsLocal, ["_rowy_ref.path", path]));
const isLocalRow = Boolean(find(tableRowsLocal, ["_rowy_ref.path", path]));
const update: Partial<TableRow> = {};
@@ -469,14 +467,6 @@ export const updateFieldAtom = atom(
deleteFields: deleteField ? [fieldName] : [],
});
// TODO(han): Formula field persistence
// const config = find(tableColumnsOrdered, (c) => {
// const [, key] = fieldName.split("_rowy_formulaValue_");
// return c.key === key;
// });
// if(!config.persist) return;
if (fieldName.startsWith("_rowy_formulaValue")) return;
// If it has no missingRequiredFields, also write to db
// And write entire row to handle the case where it doesnt exist in db yet
if (missingRequiredFields.length === 0) {

View File

@@ -6,9 +6,7 @@ import {
_deleteRowDbAtom,
_updateRowDbAtom,
tableNextPageAtom,
tableRowsAtom,
tableRowsDbAtom,
tableRowsLocalAtom,
tableScope,
tableSettingsAtom,
} from "@src/atoms/tableScope";

View File

@@ -26,6 +26,7 @@ import {
DocumentData,
or,
QueryFieldFilterConstraint,
Timestamp,
} from "firebase/firestore";
import { useErrorHandler } from "react-error-boundary";
@@ -402,6 +403,26 @@ const getQuery = <T>(
}
};
/**
* Parse datetime to Date object
* \{ nanoseconds: number; seconds: number \} is a Timestamp object without toDate() method, we need to calculate it manually
* */
const parseDateFilterValue = (
date: Date | Timestamp | { nanoseconds: number; seconds: number }
) => {
if (date instanceof Date) {
return date;
} else if ("toDate" in date) {
return date.toDate();
} else if (date.seconds) {
return new Date(date.seconds * 1000 + date.nanoseconds / 1_000_000);
} else if (date instanceof Timestamp) {
return date.toDate();
} else {
throw new Error(`Invalid date ${date}`);
}
};
/**
* Support custom filter operators not supported by Firestore.
* e.g. date-range-equal: `>=` && `<=` operators when `==` is used on dates.
@@ -414,8 +435,7 @@ export const tableFiltersToFirestoreFilters = (filters: TableFilter[]) => {
for (const filter of filters) {
if (filter.operator.startsWith("date-")) {
if (!filter.value) continue;
const filterDate =
"toDate" in filter.value ? filter.value.toDate() : filter.value;
const filterDate = parseDateFilterValue(filter.value);
const [startDate, endDate] = getDateRange(filterDate);
if (filter.operator === "date-equal") {
@@ -433,8 +453,7 @@ export const tableFiltersToFirestoreFilters = (filters: TableFilter[]) => {
continue;
} else if (filter.operator === "time-minute-equal") {
if (!filter.value) continue;
const filterDate =
"toDate" in filter.value ? filter.value.toDate() : filter.value;
const filterDate = parseDateFilterValue(filter.value);
const [startDate, endDate] = getTimeRange(filterDate);
firestoreFilters.push(where(filter.key, ">=", startDate));