aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/components/FeedSidebar.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/FeedSidebar.tsx')
-rw-r--r--frontend/src/components/FeedSidebar.tsx30
1 files changed, 21 insertions, 9 deletions
diff --git a/frontend/src/components/FeedSidebar.tsx b/frontend/src/components/FeedSidebar.tsx
index 73d9504..4f50566 100644
--- a/frontend/src/components/FeedSidebar.tsx
+++ b/frontend/src/components/FeedSidebar.tsx
@@ -1,23 +1,35 @@
-import { useQuery } from "urql";
+import { useCallback, useEffect, useState } from "react";
import { useLocation, useSearch } from "wouter";
-import { GetFeedsDocument } from "../graphql/generated/graphql";
+import type { components } from "../api/generated";
+import { api } from "../services/api-client";
+
+type Feed = components["schemas"]["Feed"];
interface Props {
basePath: string;
}
-const urqlContextFeed = { additionalTypenames: ["Feed", "Article"] };
-
export function FeedSidebar({ basePath }: Props) {
const search = useSearch();
const [, setLocation] = useLocation();
const params = new URLSearchParams(search);
const selectedFeedId = params.get("feed");
- const [{ data, fetching }] = useQuery({
- query: GetFeedsDocument,
- context: urqlContextFeed,
- });
+ const [feeds, setFeeds] = useState<Feed[]>([]);
+ const [fetching, setFetching] = useState(true);
+
+ const fetchFeeds = useCallback(async () => {
+ setFetching(true);
+ const { data } = await api.GET("/api/feeds");
+ if (data) {
+ setFeeds(data);
+ }
+ setFetching(false);
+ }, []);
+
+ useEffect(() => {
+ fetchFeeds();
+ }, [fetchFeeds]);
const handleSelect = (feedId: string | null) => {
if (feedId) {
@@ -49,7 +61,7 @@ export function FeedSidebar({ basePath }: Props) {
{fetching && (
<li className="px-3 py-1.5 text-xs text-stone-400">Loading...</li>
)}
- {data?.feeds.map((feed) => (
+ {feeds.map((feed) => (
<li key={feed.id}>
<button
type="button"