proxy / src /pages /Search.jsx
randome-games's picture
fresh deploy with fixes
dbcdc7c
Raw History Blame Contribute Delete
1.87 kB
import Tabs from '/src/components/loader/Tabs';
import Omnibox from '/src/components/loader/Omnibox';
import Viewer from '/src/components/loader/Viewer';
import Menu from '/src/components/loader/Menu';
import loaderStore from '/src/utils/hooks/loader/useLoaderStore';
import { process } from '/src/utils/hooks/loader/utils';
import { useOptions } from '../utils/optionsContext';
import { useEffect } from 'react';
export default function Loader({ config = {} }) {
const { url, ui = true, zoom, alerts = false } = config;
const { options } = useOptions();
const tabs = loaderStore((state) => state.tabs);
const updateUrl = loaderStore((state) => state.updateUrl);
const barStyle = {
backgroundColor: options.barColor || '#09121e',
};
useEffect(() => {
if (url && tabs.length > 0) {
//only 1 tab on initial load so tabs[0]
const tab = tabs[0];
const processedUrl = process(url, false, options.prType || 'scr', options.engine || null);
if (processedUrl && tab.url !== processedUrl) {
updateUrl(tab.id, processedUrl);
}
}
}, [url, tabs, updateUrl, options.prType]);
useEffect(() => {
loaderStore.getState().clearStore({ showTb: options.showTb ?? true });
}, []);
return (
<div className="flex flex-col w-full h-screen">
{ui && (
<>
<div
className="flex flex-col w-full"
style={barStyle}
onClick={() => loaderStore.getState().showMenu && loaderStore.getState().toggleMenu()}
>
<Tabs />
<Omnibox />
</div>
<Menu />
</>
)}
<div
className="flex-1 w-full"
onClick={() => loaderStore.getState().showMenu && loaderStore.getState().toggleMenu()}
>
<Viewer conf={{ zoom: zoom, alerts: alerts }} />
</div>
</div>
);
}