mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
preloading lab after flow
This commit is contained in:
parent
77d59625d1
commit
16fe237a4a
1 changed files with 10 additions and 1 deletions
|
@ -1,17 +1,26 @@
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
|
import { useAuth } from '~/hooks/auth/useAuth';
|
||||||
import { useFlowLoader } from '~/hooks/flow/useFlowLoader';
|
import { useFlowLoader } from '~/hooks/flow/useFlowLoader';
|
||||||
|
import { useLab } from '~/hooks/lab/useLab';
|
||||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||||
import { hideLoader } from '~/utils/dom/hideLoader';
|
import { hideLoader } from '~/utils/dom/hideLoader';
|
||||||
|
|
||||||
/** simply waits for all data to settle and then show the app */
|
/** simply waits for all data to settle and then show the app */
|
||||||
export const useGlobalLoader = () => {
|
export const useGlobalLoader = () => {
|
||||||
const { getInitialNodes } = useFlowLoader();
|
const { getInitialNodes } = useFlowLoader();
|
||||||
|
const { loadMore: loadLabNodes, nodes: labNodes, isLoading: isLoadingLab } = useLab();
|
||||||
|
const { isUser } = useAuth();
|
||||||
|
|
||||||
const flow = useFlowStore();
|
const flow = useFlowStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!flow.isRefreshed) {
|
if (!flow.isRefreshed) {
|
||||||
void getInitialNodes();
|
void getInitialNodes().then(() => {
|
||||||
|
if (!isUser || isLoadingLab || labNodes.length) return;
|
||||||
|
|
||||||
|
return loadLabNodes();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue