Skip to content

Commit

Permalink
feat: show login when auth error
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 7, 2023
1 parent 6f69d80 commit a3b860f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion hooks/useSummarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useToast } from "~/hooks/use-toast";
import { UserConfig, VideoConfig, VideoService } from "~/lib/types";
import { RATE_LIMIT_COUNT } from "~/utils/constants";

export function useSummarize() {
export function useSummarize(showSingIn: (show: boolean) => void) {
const [loading, setLoading] = useState(false);
const [summary, setSummary] = useState<string>("");
const { toast } = useToast();
Expand Down Expand Up @@ -57,6 +57,7 @@ export function useSummarize() {
// description: response.body
description: "每天的免费次数已经用完啦,🆓",
});
showSingIn(true);
} else {
toast({
variant: "destructive",
Expand Down
6 changes: 4 additions & 2 deletions pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import { extractUrl } from "~/utils/extractUrl";
import { getVideoIdFromUrl } from "~/utils/getVideoIdFromUrl";
import getVideoId from "get-video-id";

export const Home: NextPage = () => {
export const Home: NextPage<{
showSingIn: (show: boolean) => void;
}> = ({ showSingIn }) => {
const router = useRouter();
const urlState = router.query.slug;
const searchParams = useSearchParams();
Expand All @@ -31,7 +33,7 @@ export const Home: NextPage = () => {
const [currentVideoId, setCurrentVideoId] = useState<string>("");
const [userKey, setUserKey, remove] =
useLocalStorage<string>("user-openai-apikey");
const { loading, summary, resetSummary, summarize } = useSummarize();
const { loading, summary, resetSummary, summarize } = useSummarize(showSingIn);
const { toast } = useToast();
const { analytics } = useAnalytics();

Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function MyApp({
>
<Header showSingIn={showSingIn} />
<main className="mx-auto flex max-w-5xl flex-1 flex-col justify-center bg-white text-slate-900 antialiased dark:bg-slate-900 dark:text-slate-50">
<Component {...pageProps} />
<Component {...pageProps} showSingIn={showSingIn} />
<Analytics />
<CommandMenu />
</main>
Expand Down

0 comments on commit a3b860f

Please sign in to comment.