mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-30 06:02:00 +02:00
Remove useNavigate everywhere, and make request a query param. And convert dialog to Jotai
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { useParams } from '@tanstack/react-router';
|
||||
import { useSearch } from '@tanstack/react-router';
|
||||
import { atom, useAtomValue } from 'jotai';
|
||||
import { useEffect } from 'react';
|
||||
import { jotaiStore } from '../lib/jotai';
|
||||
|
||||
export const activeRequestIdAtom = atom<string>();
|
||||
export const activeRequestIdAtom = atom<string | null>(null);
|
||||
|
||||
export function useActiveRequestId(): string | null {
|
||||
return useAtomValue(activeRequestIdAtom) ?? null;
|
||||
return useAtomValue(activeRequestIdAtom);
|
||||
}
|
||||
|
||||
export function useSubscribeActiveRequestId() {
|
||||
const { requestId } = useParams({ strict: false });
|
||||
useEffect(() => jotaiStore.set(activeRequestIdAtom, requestId), [requestId]);
|
||||
const { request_id } = useSearch({ strict: false });
|
||||
useEffect(() => jotaiStore.set(activeRequestIdAtom, request_id ?? null), [request_id]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user