Connection State: Do not duplicate Chat List spinner

This commit is contained in:
Alexander Zinchuk 2022-02-11 15:13:10 +01:00
parent 5aa591eab5
commit f5a019e02a
2 changed files with 11 additions and 6 deletions

View File

@ -54,8 +54,9 @@ type StateProps =
theme: ISettings['theme'];
animationLevel: 0 | 1 | 2;
chatsById?: Record<string, ApiChat>;
isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized'];
isMessageListOpen: boolean;
isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized'];
areChatsLoaded?: boolean;
}
& Pick<GlobalState, 'connectionState' | 'isSyncing'>;
@ -84,14 +85,16 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
chatsById,
connectionState,
isSyncing,
isConnectionStatusMinimized,
isMessageListOpen,
isConnectionStatusMinimized,
areChatsLoaded,
}) => {
const {
openChat,
openTipsChat,
setGlobalSearchDate,
setSettingOption, setGlobalSearchChatId,
setSettingOption,
setGlobalSearchChatId,
} = getDispatch();
const lang = useLang();
@ -118,7 +121,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
}, [hasMenu, chatsById]);
const { connectionStatus, connectionStatusText, connectionStatusPosition } = useConnectionStatus(
lang, connectionState, isSyncing, isMessageListOpen, isConnectionStatusMinimized,
lang, connectionState, isSyncing, isMessageListOpen, isConnectionStatusMinimized, !areChatsLoaded,
);
const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME;
@ -361,8 +364,9 @@ export default memo(withGlobal<OwnProps>(
animationLevel,
connectionState,
isSyncing,
isConnectionStatusMinimized,
isMessageListOpen: Boolean(selectCurrentMessageList(global)),
isConnectionStatusMinimized,
areChatsLoaded: Boolean(global.chats.listIds.active),
};
},
)(LeftMainHeader));

View File

@ -21,6 +21,7 @@ export default function useConnectionStatus(
isSyncing: GlobalState['isSyncing'],
hasMiddleHeader: boolean,
isMinimized?: boolean,
isDisabled?: boolean,
) {
let status: ConnectionStatus;
const isBrowserOnline = useBrowserOnline();
@ -33,7 +34,7 @@ export default function useConnectionStatus(
}
let position: ConnectionStatusPosition;
if (status === ConnectionStatus.online) {
if (status === ConnectionStatus.online || isDisabled) {
position = 'none';
} else if (hasMiddleHeader) {
position = 'middleHeader';