From 8d9d9f5fbb76c1ba3af5cada74ec54286d4c0b04 Mon Sep 17 00:00:00 2001 From: ascibisz Date: Thu, 8 Jan 2026 13:50:24 -0800 Subject: [PATCH 1/2] Set timestamp using firebase's Timestamp.now() instead of Date.now() --- src/App.tsx | 1 - src/utils/firebase.ts | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index c330ada3..4782f5bc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -60,7 +60,6 @@ function App() { } recipeJson[FIRESTORE_FIELDS.RECIPE_PATH] = path; recipeJson[FIRESTORE_FIELDS.NAME] = id; - recipeJson[FIRESTORE_FIELDS.TIMESTAMP] = Date.now(); return recipeJson; }; diff --git a/src/utils/firebase.ts b/src/utils/firebase.ts index 14474031..dcf857a4 100644 --- a/src/utils/firebase.ts +++ b/src/utils/firebase.ts @@ -229,6 +229,10 @@ const getDocsByIds = async (coll: string, ids: string[]) => { }; const addRecipe = async (id: string, data: object) => { + data = { + ...data, + [FIRESTORE_FIELDS.TIMESTAMP]: Timestamp.now(), + }; await setDoc(doc(db, FIRESTORE_COLLECTIONS.EDITED_RECIPES, id), data); }; From 8ff06e0dbe3995084b8d76697a26d3a0f682a94d Mon Sep 17 00:00:00 2001 From: ascibisz Date: Thu, 15 Jan 2026 09:49:14 -0800 Subject: [PATCH 2/2] use new variable instead of mutating data --- src/utils/firebase.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/firebase.ts b/src/utils/firebase.ts index dcf857a4..5f8d25d4 100644 --- a/src/utils/firebase.ts +++ b/src/utils/firebase.ts @@ -229,11 +229,11 @@ const getDocsByIds = async (coll: string, ids: string[]) => { }; const addRecipe = async (id: string, data: object) => { - data = { + const timestampedData = { ...data, [FIRESTORE_FIELDS.TIMESTAMP]: Timestamp.now(), }; - await setDoc(doc(db, FIRESTORE_COLLECTIONS.EDITED_RECIPES, id), data); + await setDoc(doc(db, FIRESTORE_COLLECTIONS.EDITED_RECIPES, id), timestampedData); }; const docCleanup = async () => {