add view socket
This commit is contained in:
parent
68a9c01027
commit
0d40e4d052
@ -17,7 +17,10 @@ export function ViewPage() {
|
||||
const [selectedIdx, setSelectedIdx] = useState(0);
|
||||
|
||||
const options = useMemo(() => {
|
||||
return data?.options.map((option) => {
|
||||
if (!data || data.options.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return data.options.map((option) => {
|
||||
let fileContent = option.text || "**No Data!**";
|
||||
fileContent = marked.parse(fileContent);
|
||||
|
||||
@ -45,7 +48,7 @@ export function ViewPage() {
|
||||
`;
|
||||
return { ...option, text: fileContent };
|
||||
});
|
||||
}, [data?.options]);
|
||||
}, [data]);
|
||||
|
||||
useEffect(() => {
|
||||
socket.on("connect", () => setIsConnected(true));
|
||||
@ -68,7 +71,7 @@ export function ViewPage() {
|
||||
}
|
||||
}, [config.contentZoomLevel]);
|
||||
|
||||
if (!data) {
|
||||
if (!data || options.length === 0) {
|
||||
return (
|
||||
<div className="h-full mx-auto flex justify-center items-center">
|
||||
<div>
|
||||
@ -152,7 +155,7 @@ export function ViewPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="border-t-2 border-gray-300 flex">
|
||||
<div className="border-t-2 border-gray-300 flex h-[36px]">
|
||||
{options.map((option, optionIdx) => (
|
||||
<button
|
||||
key={option.id}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user