Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Jul 21, 2024
1 parent 314b582 commit 496c130
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion imports/orientation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const Orientation = memo(function Orientation({
onescreen: _onescreen,
insert=true,
delete: _delete=true,
usePathState = useState,
children,
}: {
query?: any;
Expand All @@ -147,6 +148,7 @@ export const Orientation = memo(function Orientation({
onescreen?: boolean;
insert?: boolean;
delete?: boolean;
usePathState?: typeof useState;
children?: any;
}) {
const deep = useDeep();
Expand Down Expand Up @@ -260,7 +262,7 @@ export const Orientation = memo(function Orientation({
}),
}), []);

const [path, setPath] = useState<PathI>([
const [path, setPath] = usePathState<PathI>([
{
key: itemsCounter++,
query: query || queries.contains(deep.linkId),
Expand Down
28 changes: 15 additions & 13 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ export function Auth() {
<Input type="password" value={_token} onChange={e => _setToken(e.target.value)} placeholder="token" w='100%' size='md' onKeyDown={e => e.key === 'Enter' && enter()}/>
</VStack>
<Flex>
<Button variant='danger' w="3em" h="3em" onClick={() => {
setPath('');
setToken('');
}}>
<IoExitOutline/>
</Button>
<Spacer/>
<Button variant="active" w="3em" h="3em" onClick={enter}>
<IoEnterOutline/>
Expand All @@ -205,15 +199,25 @@ export function Auth() {
}}>
<IoMdPersonAdd/>
</Button>
<Button variant='danger' w="3em" h="3em" onClick={() => {
setPath('');
setToken('');
}}>
<IoExitOutline/>
</Button>
</Flex>
</Box>
</Box>;
}

export function Content() {
export function usePathState(defaultValue) {
// return useQueryStore('orientation', defaultValue);
return useState(defaultValue);
}

export const Content = memo(function Content() {
const deep = useDeep();
const { t } = useTranslation();
const router = useRouter();

(global as any).deep = deep;
(global as any).ml = deep?.minilinks;
Expand All @@ -237,7 +241,7 @@ export function Content() {
}, []);

return (<>
{[<Orientation key={deep.linkId} scope='deep' linkId={deep.linkId}>
{[<Orientation key={deep?.linkId} scope='deep' linkId={deep?.linkId} usePathState={usePathState as any}>
<Grid
templateAreas={`"tabs tabs"
"nav main"`}
Expand Down Expand Up @@ -309,7 +313,7 @@ export function Content() {
// <Box flex='1' bg='tomato' overflow="hidden">
// </Box>
// </Flex>);
};
}, () => true);

export default function Page({
defaultPath,
Expand All @@ -335,9 +339,7 @@ export default function Page({
<FinderProvider>
<DeepNamespaceProvider>
<MinilinksProvider>
{!!path && <>
</>}
{<AutoGuest/>}
<AutoGuest/>
<Mounted>
<Content/>
</Mounted>
Expand Down

0 comments on commit 496c130

Please sign in to comment.