* handle client boot error in loading screen * use sync state hook in client root * add loading screen options * removed extra condition in loading finish * add sync connection status bar
26 lines
760 B
JavaScript
26 lines
760 B
JavaScript
/* eslint-disable import/prefer-default-export */
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import { hasCrossSigningAccountData } from '../../util/matrixUtil';
|
|
import { useMatrixClient } from './useMatrixClient';
|
|
|
|
export function useCrossSigningStatus() {
|
|
const mx = useMatrixClient();
|
|
const [isCSEnabled, setIsCSEnabled] = useState(hasCrossSigningAccountData(mx));
|
|
|
|
useEffect(() => {
|
|
if (isCSEnabled) return undefined;
|
|
const handleAccountData = (event) => {
|
|
if (event.getType() === 'm.cross_signing.master') {
|
|
setIsCSEnabled(true);
|
|
}
|
|
};
|
|
|
|
mx.on('accountData', handleAccountData);
|
|
return () => {
|
|
mx.removeListener('accountData', handleAccountData);
|
|
};
|
|
}, [mx, isCSEnabled]);
|
|
return isCSEnabled;
|
|
}
|