diff --git a/src/app/(tabs)/search/index.tsx b/src/app/(tabs)/search/index.tsx index 4bd2adc..6163689 100644 --- a/src/app/(tabs)/search/index.tsx +++ b/src/app/(tabs)/search/index.tsx @@ -20,7 +20,12 @@ import PreviewCard from '../../../components/PreviewCard/PreviewCard'; import RecentSearchCard from '../../../components/RecentSearchCard/RecentSearchCard'; import { fetchGenres } from '../../../queries/genres'; import { fetchAllStoryPreviews } from '../../../queries/stories'; -import { StoryPreview, RecentSearch, Genre, StoryPreviewWithPreloadedReactions } from '../../../queries/types'; +import { + StoryPreview, + RecentSearch, + Genre, + StoryPreviewWithPreloadedReactions, +} from '../../../queries/types'; import colors from '../../../styles/colors'; import globalStyles from '../../../styles/globalStyles'; import { GenreType } from '../genre'; @@ -62,9 +67,13 @@ const setRecentStory = async (recentStories: StoryPreview[]) => { }; function SearchScreen() { - const [allStories, setAllStories] = useState([]); + const [allStories, setAllStories] = useState< + StoryPreviewWithPreloadedReactions[] + >([]); const [allGenres, setAllGenres] = useState([]); - const [searchResults, setSearchResults] = useState([]); + const [searchResults, setSearchResults] = useState< + StoryPreviewWithPreloadedReactions[] + >([]); const [search, setSearch] = useState(''); const [filterVisible, setFilterVisible] = useState(false); const [recentSearches, setRecentSearches] = useState([]); @@ -75,9 +84,7 @@ function SearchScreen() { useEffect(() => { (async () => { - fetchAllStoryPreviews().then((stories) => - setAllStories(stories), - ); + fetchAllStoryPreviews().then(stories => setAllStories(stories)); fetchGenres().then((genres: Genre[]) => setAllGenres(genres)); getRecentSearch().then((searches: RecentSearch[]) => setRecentSearches(searches), diff --git a/src/components/PreviewCard/PreviewCard.tsx b/src/components/PreviewCard/PreviewCard.tsx index efc6cfd..b6cb634 100644 --- a/src/components/PreviewCard/PreviewCard.tsx +++ b/src/components/PreviewCard/PreviewCard.tsx @@ -40,17 +40,17 @@ function PreviewCard({ excerpt, tags, pressFunction, - reactions: preloadedReactions = null + reactions: preloadedReactions = null, }: PreviewCardProps) { - const [reactions, setReactions] = useState(preloadedReactions); + const [reactions, setReactions] = useState( + preloadedReactions, + ); useEffect(() => { if (preloadedReactions != null) { return; } (async () => { - console.log("fetching reactions"); - const temp = await fetchAllReactionsToStory(storyId); if (temp != null) { setReactions(temp.map(r => r.reaction)); diff --git a/src/queries/stories.tsx b/src/queries/stories.tsx index 0dffc35..e48dc51 100644 --- a/src/queries/stories.tsx +++ b/src/queries/stories.tsx @@ -1,7 +1,14 @@ -import { Story, StoryPreview, StoryCard, StoryPreviewWithPreloadedReactions } from './types'; +import { + Story, + StoryPreview, + StoryCard, + StoryPreviewWithPreloadedReactions, +} from './types'; import supabase from '../utils/supabase'; -export async function fetchAllStoryPreviews(): Promise { +export async function fetchAllStoryPreviews(): Promise< + StoryPreviewWithPreloadedReactions[] +> { const { data, error } = await supabase.rpc('fetch_all_story_previews'); if (error) { diff --git a/src/queries/types.tsx b/src/queries/types.tsx index b349433..a7ce63a 100644 --- a/src/queries/types.tsx +++ b/src/queries/types.tsx @@ -25,7 +25,6 @@ export interface StoryPreviewWithPreloadedReactions { reactions: string[]; } - export interface Author { id: number; name: string;