mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 15:07:54 -04:00
* init * changes * Now updating statistics once a minute * More robust statistics updater * Concurrency is hard * improvements to stats * refactor * adjust setting back/forward padding so it matches top bar * refactor sidebar * rename * setting up screens * some changes * Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com> * yes * yes2 * refactored explorerItem.ts * important explorer code shouldn't be thrown away in a util moment * support for multiple thumbnails in ExplorerItem * clippy * move debug * yes * label filters * ts * comment out unconnected stuff * added .mid for midi files --------- Co-authored-by: Ericson Fogo Soares <ericson.ds999@gmail.com> Co-authored-by: Brendan Allan <brendonovich@outlook.com>
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { useDiscoveredPeers } from '@sd/client';
|
|
import { Icon } from '~/components';
|
|
import { useLocale } from '~/hooks';
|
|
import { useRouteTitle } from '~/hooks/useRouteTitle';
|
|
|
|
import Explorer from './Explorer';
|
|
import { ExplorerContextProvider } from './Explorer/Context';
|
|
import { createDefaultExplorerSettings, nonIndexedPathOrderingSchema } from './Explorer/store';
|
|
import { DefaultTopBarOptions } from './Explorer/TopBarOptions';
|
|
import { useExplorer, useExplorerSettings } from './Explorer/useExplorer';
|
|
import { TopBarPortal } from './TopBar/Portal';
|
|
|
|
export const Component = () => {
|
|
const title = useRouteTitle('Network');
|
|
|
|
const { t } = useLocale();
|
|
|
|
const discoveredPeers = useDiscoveredPeers();
|
|
const peers = useMemo(() => Array.from(discoveredPeers.values()), [discoveredPeers]);
|
|
|
|
const explorerSettings = useExplorerSettings({
|
|
settings: useMemo(
|
|
() =>
|
|
createDefaultExplorerSettings({
|
|
order: {
|
|
field: 'name',
|
|
value: 'Asc'
|
|
}
|
|
}),
|
|
[]
|
|
),
|
|
orderingKeys: nonIndexedPathOrderingSchema
|
|
});
|
|
|
|
const explorer = useExplorer({
|
|
items: peers.map((peer) => ({
|
|
type: 'SpacedropPeer' as const,
|
|
has_local_thumbnail: false,
|
|
thumbnail: null,
|
|
item: {
|
|
...peer,
|
|
pub_id: []
|
|
}
|
|
})),
|
|
settings: explorerSettings,
|
|
layouts: { media: false }
|
|
});
|
|
|
|
return (
|
|
<ExplorerContextProvider explorer={explorer}>
|
|
<TopBarPortal
|
|
left={
|
|
<div className="flex items-center gap-2">
|
|
<Icon name="Globe" size={22} />
|
|
<span className="truncate text-sm font-medium">{title}</span>
|
|
</div>
|
|
}
|
|
right={<DefaultTopBarOptions />}
|
|
/>
|
|
<Explorer
|
|
emptyNotice={
|
|
<div className="flex h-full flex-col items-center justify-center text-white">
|
|
<Icon name="Globe" size={128} />
|
|
<h1 className="mt-4 text-lg font-bold">{t('your_local_network')}</h1>
|
|
<p className="mt-1 max-w-sm text-center text-sm text-ink-dull">
|
|
{t('network_page_description')}
|
|
</p>
|
|
</div>
|
|
}
|
|
/>
|
|
</ExplorerContextProvider>
|
|
);
|
|
};
|