mirror of https://github.com/msgbyte/tailchat
feat: add navbar icon which can jump to active panel
parent
c7497cc79e
commit
95c589df4f
@ -0,0 +1,17 @@
|
|||||||
|
import { useNavigate } from '@capital/common';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { useLivekitState } from '../store/useLivekitState';
|
||||||
|
|
||||||
|
export const LivekitNavbarRedirect: React.FC = React.memo(() => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { isActive, url } = useLivekitState();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isActive) {
|
||||||
|
navigate(url);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return <div>Redirect...</div>;
|
||||||
|
});
|
||||||
|
LivekitNavbarRedirect.displayName = 'LivekitNavbarRedirect';
|
@ -0,0 +1,5 @@
|
|||||||
|
import { useLivekitState } from '../store/useLivekitState';
|
||||||
|
|
||||||
|
export function useIconIsShow() {
|
||||||
|
return useLivekitState().isActive;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
import { create } from 'zustand';
|
||||||
|
import { immer } from 'zustand/middleware/immer';
|
||||||
|
|
||||||
|
interface LivekitState {
|
||||||
|
isActive: boolean;
|
||||||
|
url: string;
|
||||||
|
setActive: (url: string) => void;
|
||||||
|
setDeactive: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useLivekitState = create<LivekitState>()(
|
||||||
|
immer((set) => ({
|
||||||
|
isActive: false,
|
||||||
|
url: '',
|
||||||
|
setActive(url) {
|
||||||
|
set((state) => {
|
||||||
|
state.isActive = true;
|
||||||
|
state.url = url;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setDeactive() {
|
||||||
|
set((state) => {
|
||||||
|
state.isActive = false;
|
||||||
|
state.url = '';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
);
|
Loading…
Reference in New Issue