groups-pane: refining loading strategy to be more efficient

This commit is contained in:
Hunter Miller 2022-04-01 12:18:43 -05:00
parent 65e05fbf25
commit c3b491ddb0
2 changed files with 24 additions and 4 deletions

View File

@ -57,4 +57,13 @@ export async function bootstrapApi() {
useSettingsState.getState().getAll();
gcpManager.start();
const {
getKeys,
getShallowChildren
} = useGraphState.getState();
useHarkState.getState().getUnreads();
getKeys();
getShallowChildren(`~${window.ship}`, 'dm-inbox');
}

View File

@ -27,6 +27,7 @@ import { UnjoinedResource } from '~/views/components/UnjoinedResource';
import { NewChannel } from './NewChannel';
import { GroupHome } from './Home/GroupHome';
import useGraphState from '~/logic/state/graph';
import { deSig } from '@urbit/api';
interface GroupsPaneProps {
baseUrl: string;
@ -59,17 +60,27 @@ export function GroupsPane(props: GroupsPaneProps) {
useEffect(() => {
const {
graphs,
graphKeys,
getKeys,
getShallowChildren
} = useGraphState.getState();
const dmGraph = graphs[`${deSig(window.ship)}/dm-inbox`];
console.log(graphs, dmGraph);
useHarkState.getState().getUnreads();
getKeys();
if (graphKeys.size === 0) {
getKeys();
}
if (location.pathname.startsWith('/~landscape/messages')) {
const { unreads, getUnreads } = useHarkState.getState();
if (Object.keys(unreads).length === 0) {
getUnreads();
}
if (location.pathname.startsWith('/~landscape/messages') && !dmGraph) {
getShallowChildren(`~${window.ship}`, 'dm-inbox');
}
}, []);
}, [location]);
useEffect(() => {
if (workspace.type !== 'group') {