move appStartup stuff todo on start

pull/1576/head
Audric Ackermann 4 years ago
parent 1720b6b627
commit 75cc39e9e7
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'; import React, { Dispatch, useEffect, useState } from 'react';
import { SessionIconButton, SessionIconSize, SessionIconType } from './icon'; import { SessionIconButton, SessionIconSize, SessionIconType } from './icon';
import { Avatar, AvatarSize } from '../Avatar'; import { Avatar, AvatarSize } from '../Avatar';
import { darkTheme, lightTheme } from '../../state/ducks/SessionTheme'; import { darkTheme, lightTheme } from '../../state/ducks/SessionTheme';
@ -31,7 +31,7 @@ import { showLeftPaneSection } from '../../state/ducks/section';
import { cleanUpOldDecryptedMedias } from '../../session/crypto/DecryptedAttachmentsManager'; import { cleanUpOldDecryptedMedias } from '../../session/crypto/DecryptedAttachmentsManager';
import { OpenGroupManagerV2 } from '../../opengroup/opengroupV2/OpenGroupManagerV2'; import { OpenGroupManagerV2 } from '../../opengroup/opengroupV2/OpenGroupManagerV2';
import { loadDefaultRoomsIfNeeded } from '../../opengroup/opengroupV2/ApiUtil'; import { loadDefaultRooms } from '../../opengroup/opengroupV2/ApiUtil';
// tslint:disable-next-line: no-import-side-effect no-submodule-imports // tslint:disable-next-line: no-import-side-effect no-submodule-imports
export enum SectionType { export enum SectionType {
@ -131,18 +131,9 @@ const showResetSessionIDDialogIfNeeded = async () => {
const cleanUpMediasInterval = MINUTES * 30; const cleanUpMediasInterval = MINUTES * 30;
/** /**
* ActionsPanel is the far left banner (not the left pane). * This function is called only once: on app startup with a logged in user
* The panel with buttons to switch between the message/contact/settings/theme views
*/ */
export const ActionsPanel = () => { const doAppStartUp = (dispatch: Dispatch<any>) => {
const dispatch = useDispatch();
const [startCleanUpMedia, setStartCleanUpMedia] = useState(false);
const ourPrimaryConversation = useSelector(getOurPrimaryConversation);
// this maxi useEffect is called only once: when the component is mounted.
// For the action panel, it means this is called only one per app start/with a user loggedin
useEffect(() => {
if (window.lokiFeatureFlags.useOnionRequests || window.lokiFeatureFlags.useFileOnionRequests) { if (window.lokiFeatureFlags.useOnionRequests || window.lokiFeatureFlags.useFileOnionRequests) {
// Initialize paths for onion requests // Initialize paths for onion requests
void OnionPaths.getInstance().buildNewOnionPaths(); void OnionPaths.getInstance().buildNewOnionPaths();
@ -179,7 +170,23 @@ export const ActionsPanel = () => {
void OpenGroupManagerV2.getInstance().startPolling(); void OpenGroupManagerV2.getInstance().startPolling();
void syncConfiguration(); void syncConfiguration();
void loadDefaultRoomsIfNeeded(); void loadDefaultRooms();
};
/**
* ActionsPanel is the far left banner (not the left pane).
* The panel with buttons to switch between the message/contact/settings/theme views
*/
export const ActionsPanel = () => {
const dispatch = useDispatch();
const [startCleanUpMedia, setStartCleanUpMedia] = useState(false);
const ourPrimaryConversation = useSelector(getOurPrimaryConversation);
// this maxi useEffect is called only once: when the component is mounted.
// For the action panel, it means this is called only one per app start/with a user loggedin
useEffect(() => {
void doAppStartUp(dispatch);
}, []); }, []);
// wait for cleanUpMediasInterval and then start cleaning up medias // wait for cleanUpMediasInterval and then start cleaning up medias

@ -133,7 +133,7 @@ const loadDefaultRoomsSingle = () =>
}; };
}); });
} catch (e) { } catch (e) {
window.log.warn('loadDefaultRoomsIfNeeded failed', e); window.log.warn('loadDefaultRoomloadDefaultRoomssIfNeeded failed', e);
} }
return []; return [];
} }
@ -145,7 +145,7 @@ const loadDefaultRoomsSingle = () =>
* Load to the cache all the details of the room of the default opengroupv2 server * Load to the cache all the details of the room of the default opengroupv2 server
* This call will only run once at a time. * This call will only run once at a time.
*/ */
export const loadDefaultRoomsIfNeeded = async () => { export const loadDefaultRooms = async () => {
// FIXME audric do the UI and refresh this list from time to time // FIXME audric do the UI and refresh this list from time to time
const allRooms: Array<OpenGroupV2InfoJoinable> = await loadDefaultRoomsSingle(); const allRooms: Array<OpenGroupV2InfoJoinable> = await loadDefaultRoomsSingle();
if (allRooms !== undefined) { if (allRooms !== undefined) {

Loading…
Cancel
Save