Fix activity replay after refresh
This commit is contained in:
@@ -45,6 +45,7 @@ type ActivityContextValue = {
|
||||
selectedId: string | null;
|
||||
sessionId: string | null;
|
||||
filesRefreshToken: number;
|
||||
openActivity: () => void;
|
||||
openItem: (id: string) => void;
|
||||
openFiles: (sessionId?: string | null) => void;
|
||||
close: () => void;
|
||||
@@ -58,6 +59,11 @@ export function ActivityProvider({ children }: { children: ReactNode }) {
|
||||
const [selectedId, setSelectedId] = useState<string | null>(null);
|
||||
const [sessionId, setSessionId] = useState<string | null>(null);
|
||||
const [filesRefreshToken, setFilesRefreshToken] = useState(0);
|
||||
const openActivity = useCallback(() => {
|
||||
setMode("activity");
|
||||
setSelectedId(null);
|
||||
setOpen(true);
|
||||
}, []);
|
||||
const openItem = useCallback((id: string) => {
|
||||
setMode("activity");
|
||||
setSelectedId(id);
|
||||
@@ -82,6 +88,7 @@ export function ActivityProvider({ children }: { children: ReactNode }) {
|
||||
selectedId,
|
||||
sessionId,
|
||||
filesRefreshToken,
|
||||
openActivity,
|
||||
openItem,
|
||||
openFiles,
|
||||
close,
|
||||
@@ -92,6 +99,7 @@ export function ActivityProvider({ children }: { children: ReactNode }) {
|
||||
selectedId,
|
||||
sessionId,
|
||||
filesRefreshToken,
|
||||
openActivity,
|
||||
openItem,
|
||||
openFiles,
|
||||
close,
|
||||
@@ -133,6 +141,7 @@ export function ActivityPanel() {
|
||||
selectedId,
|
||||
sessionId,
|
||||
filesRefreshToken,
|
||||
openActivity,
|
||||
openItem,
|
||||
close,
|
||||
} = useActivityPanel();
|
||||
@@ -151,10 +160,10 @@ export function ActivityPanel() {
|
||||
latestId &&
|
||||
latestId !== prevLatestIdRef.current
|
||||
) {
|
||||
openItem(latestId);
|
||||
openActivity();
|
||||
}
|
||||
prevLatestIdRef.current = latestId;
|
||||
}, [items, mode, openItem]);
|
||||
}, [items, mode, openActivity]);
|
||||
|
||||
if (!open) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user