Skip to content

Commit

Permalink
キャッシュクリア対応 (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadabee authored Dec 13, 2024
1 parent 50843a2 commit 6bcfeab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/web/src/pages/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { MODELS } from '../hooks/useModel';
import useGitHub, { PullRequest } from '../hooks/useGitHub';
import { PiGithubLogoFill, PiArrowSquareOut } from 'react-icons/pi';
import { useAuthenticator } from '@aws-amplify/ui-react';
import { useCallback } from 'react';
import { useSWRConfig } from 'swr';

const ragEnabled: boolean = import.meta.env.VITE_APP_RAG_ENABLED === 'true';
const ragKnowledgeBaseEnabled: boolean =
Expand All @@ -33,6 +35,7 @@ const SettingItem = (props: {

const Setting = () => {
const { modelRegion, modelIds, imageGenModelIds, agentNames } = MODELS;
const { cache } = useSWRConfig();
const { getLocalVersion, getHasUpdate } = useVersion();
const { getClosedPullRequests } = useGitHub();
const { signOut } = useAuthenticator();
Expand All @@ -41,6 +44,14 @@ const Setting = () => {
const hasUpdate = getHasUpdate();
const closedPullRequests = getClosedPullRequests();

const onClickSignout = useCallback(() => {
// SWRのキャッシュを全て削除する
for (const key of cache.keys()) {
cache.delete(key);
}
signOut();
}, [cache, signOut]);

return (
<div>
<div className="invisible my-0 flex h-0 items-center justify-center text-xl font-semibold lg:visible lg:my-5 lg:h-min print:visible print:my-5 print:h-min">
Expand Down Expand Up @@ -150,7 +161,7 @@ const Setting = () => {
</div>

<div className="my-10 flex w-full justify-center">
<Button onClick={signOut} className="text-lg">
<Button onClick={onClickSignout} className="text-lg">
サインアウト
</Button>
</div>
Expand Down

0 comments on commit 6bcfeab

Please sign in to comment.