mirror of
https://github.com/balzack/databag.git
synced 2025-05-05 07:55:15 +00:00
render app loading indicator
This commit is contained in:
parent
28e19034fd
commit
286f523fd9
@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useContext } from 'react';
|
import { useEffect, useContext } from 'react';
|
||||||
import { Drawer } from 'antd';
|
import { Drawer, Spin } from 'antd';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { SessionWrapper } from './Session.styled';
|
import { SessionWrapper } from './Session.styled';
|
||||||
import { AppContext } from 'context/AppContext';
|
import { AppContext } from 'context/AppContext';
|
||||||
@ -76,6 +76,13 @@ export function Session() {
|
|||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<Channels open={openConversation} />
|
<Channels open={openConversation} />
|
||||||
</div>
|
</div>
|
||||||
|
{ state.loading && (
|
||||||
|
<div class="reframe">
|
||||||
|
<div class="spinner">
|
||||||
|
<Spin size="large" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<div class="reframe">
|
<div class="reframe">
|
||||||
@ -131,6 +138,13 @@ export function Session() {
|
|||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<Channels open={actions.openConversation} />
|
<Channels open={actions.openConversation} />
|
||||||
</div>
|
</div>
|
||||||
|
{ state.loading && (
|
||||||
|
<div class="reframe">
|
||||||
|
<div class="spinner">
|
||||||
|
<Spin size="large" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<div class="reframe">
|
<div class="reframe">
|
||||||
@ -210,6 +224,13 @@ export function Session() {
|
|||||||
<Profile />
|
<Profile />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{ state.loading && (
|
||||||
|
<div class="reframe">
|
||||||
|
<div class="spinner">
|
||||||
|
<Spin size="large" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<BottomNav state={state} actions={actions} />
|
<BottomNav state={state} actions={actions} />
|
||||||
|
@ -9,6 +9,15 @@ export const SessionWrapper = styled.div`
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: rgba(0,0,0,0.1);
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.desktop-layout {
|
.desktop-layout {
|
||||||
|
@ -4,6 +4,7 @@ import { CardContext } from 'context/CardContext';
|
|||||||
import { ChannelContext } from 'context/ChannelContext';
|
import { ChannelContext } from 'context/ChannelContext';
|
||||||
import { ConversationContext } from 'context/ConversationContext';
|
import { ConversationContext } from 'context/ConversationContext';
|
||||||
import { UploadContext } from 'context/UploadContext';
|
import { UploadContext } from 'context/UploadContext';
|
||||||
|
import { StoreContext } from 'context/StoreContext';
|
||||||
|
|
||||||
export function useConversation(cardId, channelId) {
|
export function useConversation(cardId, channelId) {
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ export function useConversation(cardId, channelId) {
|
|||||||
const channel = useContext(ChannelContext);
|
const channel = useContext(ChannelContext);
|
||||||
const conversation = useContext(ConversationContext);
|
const conversation = useContext(ConversationContext);
|
||||||
const upload = useContext(UploadContext);
|
const upload = useContext(UploadContext);
|
||||||
|
const store = useContext(StoreContext);
|
||||||
|
|
||||||
const updateState = (value) => {
|
const updateState = (value) => {
|
||||||
setState((s) => ({ ...s, ...value }));
|
setState((s) => ({ ...s, ...value }));
|
||||||
@ -119,6 +121,8 @@ export function useConversation(cardId, channelId) {
|
|||||||
});
|
});
|
||||||
const { loadingInit, loadingMore } = conversation.state;
|
const { loadingInit, loadingMore } = conversation.state;
|
||||||
updateState({ topics, loadingInit, loadingMore });
|
updateState({ topics, loadingInit, loadingMore });
|
||||||
|
store.actions.setValue(`${channelId}::${cardId}`, Number(conversation.state.revision));
|
||||||
|
|
||||||
}, [conversation]);
|
}, [conversation]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
@ -2,6 +2,8 @@ import { useContext, useState, useEffect, useRef } from 'react';
|
|||||||
import { CardContext } from 'context/CardContext';
|
import { CardContext } from 'context/CardContext';
|
||||||
import { StoreContext } from 'context/StoreContext';
|
import { StoreContext } from 'context/StoreContext';
|
||||||
import { ViewportContext } from 'context/ViewportContext';
|
import { ViewportContext } from 'context/ViewportContext';
|
||||||
|
import { ProfileContext } from 'context/ProfileContext';
|
||||||
|
import { ChannelContext } from 'context/ChannelContext';
|
||||||
|
|
||||||
export function useSession() {
|
export function useSession() {
|
||||||
|
|
||||||
@ -18,11 +20,14 @@ export function useSession() {
|
|||||||
contact: false,
|
contact: false,
|
||||||
profile: false,
|
profile: false,
|
||||||
account: false,
|
account: false,
|
||||||
|
loading: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const card = useContext(CardContext);
|
const card = useContext(CardContext);
|
||||||
const store = useContext(StoreContext);
|
const store = useContext(StoreContext);
|
||||||
const viewport = useContext(ViewportContext);
|
const viewport = useContext(ViewportContext);
|
||||||
|
const channel = useContext(ChannelContext);
|
||||||
|
const profile = useContext(ProfileContext);
|
||||||
|
|
||||||
const storeStatus = useRef(null);
|
const storeStatus = useRef(null);
|
||||||
const cardStatus = useRef(null);
|
const cardStatus = useRef(null);
|
||||||
@ -31,6 +36,15 @@ export function useSession() {
|
|||||||
setState((s) => ({ ...s, ...value }));
|
setState((s) => ({ ...s, ...value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!profile.state.init || !card.state.init || !channel.state.init) {
|
||||||
|
updateState({ loading: true });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
updateState({ loading: false });
|
||||||
|
}
|
||||||
|
}, [card, channel, profile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateState({ display: viewport.state.display });
|
updateState({ display: viewport.state.display });
|
||||||
}, [viewport]);
|
}, [viewport]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user