From 1fcaf64f1bd8ffa019298a6a978dd28ed0f817b9 Mon Sep 17 00:00:00 2001 From: Alex Komoroske Date: Sun, 12 Nov 2023 18:41:29 -0800 Subject: [PATCH] Fix a bug where in production there are some cards in the about section without an updated timestamp. Part of #646. --- src/actions/similarity.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/actions/similarity.ts b/src/actions/similarity.ts index be95309f..5603428f 100644 --- a/src/actions/similarity.ts +++ b/src/actions/similarity.ts @@ -73,7 +73,7 @@ type SimilarCardsResponseData = { const similarCardsCallable = httpsCallable(functions, 'similarCards'); -const similarCards = async (cardID : CardID, lastUpdated : MillisecondsSinceEpoch) : Promise => { +const similarCards = async (cardID : CardID, lastUpdated? : MillisecondsSinceEpoch) : Promise => { if (!QDRANT_ENABLED) { return { success: false, @@ -83,9 +83,9 @@ const similarCards = async (cardID : CardID, lastUpdated : MillisecondsSinceEpoc } const request : SimilarCardsRequestData = { - card_id: cardID, - last_updated: lastUpdated + card_id: cardID }; + if (lastUpdated) request.last_updated = lastUpdated; const result = await similarCardsCallable(request); return result.data; }; @@ -93,7 +93,7 @@ const similarCards = async (cardID : CardID, lastUpdated : MillisecondsSinceEpoc const TIME_TO_WAIT_FOR_STALE : MillisecondsSinceEpoch = 10 * 60 * 1000; const DELAY_FOR_STALE : MillisecondsSinceEpoch = 2.5 * 1000; -const fetchSimilarCards = (cardID : CardID, lastUpdated: MillisecondsSinceEpoch) : ThunkSomeAction => async (dispatch) => { +const fetchSimilarCards = (cardID : CardID, lastUpdated?: MillisecondsSinceEpoch) : ThunkSomeAction => async (dispatch) => { if (!cardID) return; const result = await similarCards(cardID, lastUpdated); @@ -144,6 +144,6 @@ export const fetchSimilarCardsIfEnabled = (cardID : CardID) : boolean => { const card = cards[cardID]; if (!card) throw new Error(`Couldn't find card ${cardID}`); //This will return immediately. - store.dispatch(fetchSimilarCards(cardID, card.updated.toMillis())); + store.dispatch(fetchSimilarCards(cardID, card?.updated?.toMillis())); return true; }; \ No newline at end of file