bootstrap: moving data calls to relevant component so it always loads

This commit is contained in:
Hunter Miller 2022-03-31 11:07:08 -05:00
parent 687b23e519
commit 9b59f26c6c
2 changed files with 17 additions and 18 deletions

View File

@ -34,23 +34,6 @@ export async function bootstrapApi() {
await useMetadataState.getState().initialize(airlock);
const path = window.location.pathname;
const inGroup = path.startsWith('/apps/landscape/~landscape/ship');
const inDms = path.startsWith('/apps/landscape/~landscape/messages');
const {
getKeys,
getShallowChildren
} = useGraphState.getState();
if (inDms) {
getShallowChildren(`~${window.ship}`, 'dm-inbox');
}
if (inGroup || inDms) {
getKeys();
useHarkState.getState().getUnreads();
}
const subs = [
useGroupState,
useContactState,

View File

@ -4,7 +4,7 @@ import Helmet from 'react-helmet';
import { Box } from '@tlon/indigo-react';
import {
Route,
RouteComponentProps, Switch
RouteComponentProps, Switch, useLocation
} from 'react-router-dom';
import { useShortcut } from '~/logic/state/settings';
import { useLocalStorageState } from '~/logic/lib/useLocalStorageState';
@ -26,6 +26,7 @@ import { DmResource } from '~/views/apps/chat/DmResource';
import { UnjoinedResource } from '~/views/components/UnjoinedResource';
import { NewChannel } from './NewChannel';
import { GroupHome } from './Home/GroupHome';
import useGraphState from '~/logic/state/graph';
interface GroupsPaneProps {
baseUrl: string;
@ -34,6 +35,7 @@ interface GroupsPaneProps {
export function GroupsPane(props: GroupsPaneProps) {
const { baseUrl, workspace } = props;
const location = useLocation();
const associations = useMetadataState(state => state.associations);
const notificationsCount = useHarkState(state => state.notificationsCount);
@ -55,6 +57,20 @@ export function GroupsPane(props: GroupsPaneProps) {
[]
);
useEffect(() => {
const {
getKeys,
getShallowChildren
} = useGraphState.getState();
useHarkState.getState().getUnreads();
getKeys();
if (location.pathname.startsWith('/~landscape/messages')) {
getShallowChildren(`~${window.ship}`, 'dm-inbox');
}
}, []);
useEffect(() => {
if (workspace.type !== 'group') {
return;