import navigation from '../../../client/state/navigation';
import { selectTab, selectSpace } from '../../../client/action/navigation';
+import Text from '../../atoms/text/Text';
import ScrollView from '../../atoms/scroll/ScrollView';
import DrawerHeader from './DrawerHeader';
import Directs from './Directs';
function Drawer() {
+ const [systemState, setSystemState] = useState(null);
const [selectedTab, setSelectedTab] = useState(navigation.selectedTab);
const [spaceId, setSpaceId] = useState(navigation.selectedSpaceId);
else selectSpace(navigation.selectedSpacePath[lRoomIndex - 1]);
}
+ function handleSystemState(state) {
+ if (state === 'ERROR' || state === 'RECONNECTING' || state === 'STOPPED') {
+ setSystemState({ status: 'Connection lost!' });
+ }
+ if (systemState !== null) setSystemState(null);
+ }
+
useEffect(() => {
navigation.on(cons.events.navigation.TAB_SELECTED, onTabSelected);
navigation.on(cons.events.navigation.SPACE_SELECTED, onSpaceSelected);
initMatrix.roomList.removeListener(cons.events.roomList.ROOM_LEAVED, onRoomLeaved);
};
}, []);
+ useEffect(() => {
+ initMatrix.matrixClient.on('sync', handleSystemState);
+ return () => {
+ initMatrix.matrixClient.removeListener('sync', handleSystemState);
+ };
+ }, [systemState]);
+
return (
<div className="drawer">
<DrawerHeader selectedTab={selectedTab} spaceId={spaceId} />
</ScrollView>
</div>
</div>
+ { systemState !== null && (
+ <div className="drawer__state">
+ <Text>{systemState.status}</Text>
+ </div>
+ )}
</div>
);
}
@extend .drawer-flexItem;
@extend .drawer-flexBox;
}
+
+ &__state {
+ padding: var(--sp-extra-tight);
+ border-top: 1px solid var(--bg-surface-border);
+ display: flex;
+ justify-content: center;
+
+ & .text {
+ color: var(--tc-danger-high);
+ }
+ }
}
.rooms__wrapper {
@extend .drawer-flexItem;