diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-11-08 17:48:54 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-11-08 17:48:54 +0900 |
| commit | 79c3528bbcd82c6eed67b17747ded31af09a4a64 (patch) | |
| tree | 0b544d66cfb70cdce15b005b6dffbe4aeb218248 | |
| parent | 6dbc5bbcacf99e4941ee8e1fb67bd132d0f517ed (diff) | |
| download | feedaka-79c3528bbcd82c6eed67b17747ded31af09a4a64.tar.gz feedaka-79c3528bbcd82c6eed67b17747ded31af09a4a64.tar.zst feedaka-79c3528bbcd82c6eed67b17747ded31af09a4a64.zip | |
fix(frontend): Fix incorrect caching settingsv0.4.1
| -rw-r--r-- | frontend/src/components/AddFeedForm.tsx | 4 | ||||
| -rw-r--r-- | frontend/src/components/ArticleItem.tsx | 8 | ||||
| -rw-r--r-- | frontend/src/components/FeedItem.tsx | 8 | ||||
| -rw-r--r-- | frontend/src/components/FeedList.tsx | 3 | ||||
| -rw-r--r-- | frontend/src/contexts/AuthContext.tsx | 10 | ||||
| -rw-r--r-- | frontend/src/pages/ReadArticles.tsx | 3 | ||||
| -rw-r--r-- | frontend/src/pages/UnreadArticles.tsx | 3 | ||||
| -rw-r--r-- | justfile | 5 |
8 files changed, 33 insertions, 11 deletions
diff --git a/frontend/src/components/AddFeedForm.tsx b/frontend/src/components/AddFeedForm.tsx index 519f9e3..6d18318 100644 --- a/frontend/src/components/AddFeedForm.tsx +++ b/frontend/src/components/AddFeedForm.tsx @@ -8,6 +8,8 @@ interface Props { onFeedAdded?: () => void; } +const urqlContextFeed = { additionalTypenames: ["Feed"] }; + export function AddFeedForm({ onFeedAdded }: Props) { const [url, setUrl] = useState(""); const [error, setError] = useState<string | null>(null); @@ -20,7 +22,7 @@ export function AddFeedForm({ onFeedAdded }: Props) { setError(null); try { - const result = await addFeed({ url: url.trim() }); + const result = await addFeed({ url: url.trim() }, urqlContextFeed); if (result.error) { setError(result.error.message); } else if (result.data) { diff --git a/frontend/src/components/ArticleItem.tsx b/frontend/src/components/ArticleItem.tsx index 4942518..c61923a 100644 --- a/frontend/src/components/ArticleItem.tsx +++ b/frontend/src/components/ArticleItem.tsx @@ -20,6 +20,8 @@ interface Props { onReadChange?: (articleId: string, isRead: boolean) => void; } +const urqlContextArticle = { additionalTypenames: ["Article"] }; + export function ArticleItem({ article, onReadChange }: Props) { const [, markArticleRead] = useMutation(MarkArticleReadDocument); const [, markArticleUnread] = useMutation(MarkArticleUnreadDocument); @@ -32,9 +34,9 @@ export function ArticleItem({ article, onReadChange }: Props) { onReadChange?.(articleId, newReadState); if (isCurrentlyRead) { - await markArticleUnread({ id: articleId }); + await markArticleUnread({ id: articleId }, urqlContextArticle); } else { - await markArticleRead({ id: articleId }); + await markArticleRead({ id: articleId }, urqlContextArticle); } }; @@ -43,7 +45,7 @@ export function ArticleItem({ article, onReadChange }: Props) { window.open(article.url, "_blank", "noreferrer"); if (!article.isRead) { onReadChange?.(article.id, true); - await markArticleRead({ id: article.id }); + await markArticleRead({ id: article.id }, urqlContextArticle); } }; diff --git a/frontend/src/components/FeedItem.tsx b/frontend/src/components/FeedItem.tsx index 29cd531..80c8992 100644 --- a/frontend/src/components/FeedItem.tsx +++ b/frontend/src/components/FeedItem.tsx @@ -15,17 +15,19 @@ interface Props { onFeedUnsubscribed?: () => void; } +const urqlContextFeed = { additionalTypenames: ["Feed"] }; + export function FeedItem({ feed, onFeedUnsubscribed }: Props) { const [, markFeedRead] = useMutation(MarkFeedReadDocument); const [, markFeedUnread] = useMutation(MarkFeedUnreadDocument); const [, unsubscribeFeed] = useMutation(UnsubscribeFeedDocument); const handleMarkAllRead = async (feedId: string) => { - await markFeedRead({ id: feedId }); + await markFeedRead({ id: feedId }, urqlContextFeed); }; const handleMarkAllUnread = async (feedId: string) => { - await markFeedUnread({ id: feedId }); + await markFeedUnread({ id: feedId }, urqlContextFeed); }; const handleUnsubscribeFeed = async (feedId: string) => { @@ -33,7 +35,7 @@ export function FeedItem({ feed, onFeedUnsubscribed }: Props) { "Are you sure you want to unsubscribe from this feed?", ); if (confirmed) { - await unsubscribeFeed({ id: feedId }); + await unsubscribeFeed({ id: feedId }, urqlContextFeed); onFeedUnsubscribed?.(); } }; diff --git a/frontend/src/components/FeedList.tsx b/frontend/src/components/FeedList.tsx index d1d7bf3..6081293 100644 --- a/frontend/src/components/FeedList.tsx +++ b/frontend/src/components/FeedList.tsx @@ -6,9 +6,12 @@ interface Props { onFeedUnsubscribed?: () => void; } +const urqlContextFeed = { additionalTypenames: ["Feed"] }; + export function FeedList({ onFeedUnsubscribed }: Props) { const [{ data, fetching, error }] = useQuery({ query: GetFeedsDocument, + context: urqlContextFeed, }); if (fetching) { diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index 761cc0f..36f2b9f 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -17,11 +17,14 @@ interface AuthContextType { const AuthContext = createContext<AuthContextType | undefined>(undefined); +const urqlContextUser = { additionalTypenames: ["User"] }; + export function AuthProvider({ children }: { children: ReactNode }) { const [, executeLogin] = useMutation(LoginDocument); const [, executeLogout] = useMutation(LogoutDocument); const [currentUserResult] = useQuery({ query: GetCurrentUserDocument, + context: urqlContextUser, }); const isLoggedIn = !!currentUserResult.data?.currentUser; @@ -32,7 +35,10 @@ export function AuthProvider({ children }: { children: ReactNode }) { password: string, ): Promise<LoginResult> => { try { - const result = await executeLogin({ username, password }); + const result = await executeLogin( + { username, password }, + urqlContextUser, + ); if (result.error) { const errorMessage = @@ -56,7 +62,7 @@ export function AuthProvider({ children }: { children: ReactNode }) { const logout = async () => { try { - await executeLogout({}); + await executeLogout({}, urqlContextUser); } catch (error) { console.error("Logout failed:", error); } diff --git a/frontend/src/pages/ReadArticles.tsx b/frontend/src/pages/ReadArticles.tsx index 74c1f5c..ccbd2dc 100644 --- a/frontend/src/pages/ReadArticles.tsx +++ b/frontend/src/pages/ReadArticles.tsx @@ -2,9 +2,12 @@ import { useQuery } from "urql"; import { ArticleList } from "../components"; import { GetReadArticlesDocument } from "../graphql/generated/graphql"; +const urqlContextArticle = { additionalTypenames: ["Article"] }; + export function ReadArticles() { const [{ data, fetching, error }] = useQuery({ query: GetReadArticlesDocument, + context: urqlContextArticle, }); if (fetching) { diff --git a/frontend/src/pages/UnreadArticles.tsx b/frontend/src/pages/UnreadArticles.tsx index 45ae0f9..dc4c377 100644 --- a/frontend/src/pages/UnreadArticles.tsx +++ b/frontend/src/pages/UnreadArticles.tsx @@ -2,9 +2,12 @@ import { useQuery } from "urql"; import { ArticleList } from "../components"; import { GetUnreadArticlesDocument } from "../graphql/generated/graphql"; +const urqlContextArticle = { additionalTypenames: ["Article"] }; + export function UnreadArticles() { const [{ data, fetching, error }] = useQuery({ query: GetUnreadArticlesDocument, + context: urqlContextArticle, }); if (fetching) { @@ -1,8 +1,9 @@ list: @just -l -serve: - ./backend/feedaka +dev: + ./backend/feedaka & + cd frontend && npm run dev build: generate cd frontend && npm run build |
