From 2a7eaf90e72af6beae498f13368a58d81d2e8c53 Mon Sep 17 00:00:00 2001 From: Ayyub Ibrahim Date: Fri, 3 May 2024 01:38:15 -0500 Subject: [PATCH] fixed escaped comma --- packages/web/components/Alerts/SignUp.tsx | 6 +- packages/web/components/Card/BetaCard.tsx | 5 +- packages/web/components/Card/Citation.tsx | 15 +++-- .../web/components/HomeBanner/HomeBanner.tsx | 2 +- .../components/HomeResults/QueryResult.tsx | 62 ++++++++++++------- packages/web/lib/utils.ts | 2 +- 6 files changed, 58 insertions(+), 34 deletions(-) diff --git a/packages/web/components/Alerts/SignUp.tsx b/packages/web/components/Alerts/SignUp.tsx index 7035eeb..1e47696 100644 --- a/packages/web/components/Alerts/SignUp.tsx +++ b/packages/web/components/Alerts/SignUp.tsx @@ -54,8 +54,8 @@ export default function AlertSignUp({ onSignUpComplete }: AlertSignUpProps) {
); -} \ No newline at end of file +} diff --git a/packages/web/components/Card/BetaCard.tsx b/packages/web/components/Card/BetaCard.tsx index 003cac1..05905d2 100644 --- a/packages/web/components/Card/BetaCard.tsx +++ b/packages/web/components/Card/BetaCard.tsx @@ -131,7 +131,10 @@ const BetaCard = ({ card }: { card: ICard }) => { {isYouTubeURL(thumbnail?.source_url) && ( diff --git a/packages/web/components/Card/Citation.tsx b/packages/web/components/Card/Citation.tsx index 5701499..7cdd6cb 100644 --- a/packages/web/components/Card/Citation.tsx +++ b/packages/web/components/Card/Citation.tsx @@ -1,4 +1,8 @@ -import { getYouTubeEmbedUrl, getYouTubeThumbnail, isYouTubeURL } from "@/lib/utils"; +import { + getYouTubeEmbedUrl, + getYouTubeThumbnail, + isYouTubeURL, +} from "@/lib/utils"; import moment from "moment"; import "./Citation.css"; @@ -23,7 +27,8 @@ const Citation = ({ ...otherMetadata } = originalCitation; - const isYoutube = source_url && isYouTubeURL(source_url) && getYouTubeThumbnail(source_url); + const isYoutube = + source_url && isYouTubeURL(source_url) && getYouTubeThumbnail(source_url); const isUrlAvailable = source_url && source_url !== "url not available"; return ( @@ -33,7 +38,9 @@ const Citation = ({ }`} >
-

#{index + 1}: {title}

+

+ #{index + 1}: {title} +

{moment(publishedAt).fromNow()}

@@ -75,4 +82,4 @@ const Citation = ({ ); }; -export default Citation; \ No newline at end of file +export default Citation; diff --git a/packages/web/components/HomeBanner/HomeBanner.tsx b/packages/web/components/HomeBanner/HomeBanner.tsx index 8a3c1db..d75fb37 100644 --- a/packages/web/components/HomeBanner/HomeBanner.tsx +++ b/packages/web/components/HomeBanner/HomeBanner.tsx @@ -23,7 +23,7 @@ export default function HomeBanner() {

- What is New Orleans' City Council doing about + What is New Orleans' City Council doing about

{word}? diff --git a/packages/web/components/HomeResults/QueryResult.tsx b/packages/web/components/HomeResults/QueryResult.tsx index 0ddc035..65ae65b 100644 --- a/packages/web/components/HomeResults/QueryResult.tsx +++ b/packages/web/components/HomeResults/QueryResult.tsx @@ -1,13 +1,13 @@ -import { useEffect, useState } from "react"; +import { ICard } from "@/lib/api"; +import { CARD_SHOW_PATH } from "@/lib/paths"; import { supabase } from "@/lib/supabase/supabaseClient"; -import Link from "next/link"; -import moment from "moment"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faSpinner } from "@fortawesome/free-solid-svg-icons"; import { getThumbnail, getYouTubeEmbedUrl, isYouTubeURL } from "@/lib/utils"; +import { faSpinner } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import moment from "moment"; +import Link from "next/link"; +import { useEffect, useState } from "react"; import CardActions from "../Card/CardActions"; -import { ICard } from "@/lib/api"; -import { CARD_SHOW_PATH } from "@/lib/paths"; import styles from "./homeresults.module.scss"; const MAX_CHARACTERS_PREVIEW = 20000; @@ -45,9 +45,10 @@ export default function QueryResult({ card }: { card: ICard }) { const [isLoading, setIsLoading] = useState(initialLoadingState); const [responses, setResponses] = useState(card.responses || []); - const prettyCreatedAt = !!createdAt && new Date(createdAt) < new Date() - ? moment(createdAt).fromNow() - : moment().fromNow(); + const prettyCreatedAt = + !!createdAt && new Date(createdAt) < new Date() + ? moment(createdAt).fromNow() + : moment().fromNow(); const thumbnail = getThumbnail(citations || []); useEffect(() => { @@ -55,20 +56,25 @@ export default function QueryResult({ card }: { card: ICard }) { if (isLoading) { intervalId = setInterval(() => { - setMsgIndex(prevIndex => (prevIndex + 1) % LOADING_MESSAGES.length); + setMsgIndex((prevIndex) => (prevIndex + 1) % LOADING_MESSAGES.length); }, 2500); } - const channel = supabase.channel(`cards:id=eq.${card.id}`) - .on("postgres_changes", { event: "UPDATE", schema: "public" }, (payload) => { - if (payload.new.id === card.id && payload.new.responses) { - const newResponses = payload.new.responses; - if (JSON.stringify(newResponses) !== JSON.stringify(responses)) { - setResponses(newResponses); - setIsLoading(false); + const channel = supabase + .channel(`cards:id=eq.${card.id}`) + .on( + "postgres_changes", + { event: "UPDATE", schema: "public" }, + (payload) => { + if (payload.new.id === card.id && payload.new.responses) { + const newResponses = payload.new.responses; + if (JSON.stringify(newResponses) !== JSON.stringify(responses)) { + setResponses(newResponses); + setIsLoading(false); + } } } - }) + ) .subscribe(); return () => { @@ -77,8 +83,9 @@ export default function QueryResult({ card }: { card: ICard }) { }; }, [card.id, isLoading, responses]); - const combinedResponses = responses.map(r => r.response).join(" "); - const previewText = combinedResponses.split(" ").slice(0, 100).join(" ") + "..."; + const combinedResponses = responses.map((r) => r.response).join(" "); + const previewText = + combinedResponses.split(" ").slice(0, 100).join(" ") + "..."; const CardBody = () => ( @@ -96,7 +103,10 @@ export default function QueryResult({ card }: { card: ICard }) { {isYouTubeURL(thumbnail?.source_url) && ( @@ -117,10 +127,14 @@ export default function QueryResult({ card }: { card: ICard }) { return (
-
+
); -} \ No newline at end of file +} diff --git a/packages/web/lib/utils.ts b/packages/web/lib/utils.ts index 116146c..f370151 100644 --- a/packages/web/lib/utils.ts +++ b/packages/web/lib/utils.ts @@ -41,4 +41,4 @@ export function getYouTubeEmbedUrl( } return `https://www.youtube.com/embed/${videoId}?autoplay=0&start=${startTime}`; -} \ No newline at end of file +}