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