Skip to content

Commit

Permalink
fix: display MLS device details when MLS is active (#18433)
Browse files Browse the repository at this point in the history
* fix: display MLS device details when MLS is active

* fix: dont display get a certificate button without E2EI enabled
  • Loading branch information
aweiss-dev authored Dec 5, 2024
1 parent 72f116c commit ef47e2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
12 changes: 5 additions & 7 deletions src/script/hooks/useDeviceIdentities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ import {E2EIHandler, getUsersIdentities, MLSStatuses, WireIdentity} from '../E2E

export const useUserIdentity = (userId: QualifiedId, groupId?: string, updateAfterEnrollment?: boolean) => {
const [deviceIdentities, setDeviceIdentities] = useState<WireIdentity[] | undefined>();
const getDeviceIdentity = (deviceId: string) => {
return deviceIdentities?.find(identity => identity.deviceId === deviceId);
};

const refreshDeviceIdentities = useCallback(async () => {
if (!E2EIHandler.getInstance().isE2EIEnabled() || !groupId) {
if (!groupId) {
return;
}

Expand Down Expand Up @@ -63,11 +66,6 @@ export const useUserIdentity = (userId: QualifiedId, groupId?: string, updateAft
? MLSStatuses.VALID
: MLSStatuses.NOT_ACTIVATED,

getDeviceIdentity:
deviceIdentities !== undefined
? (deviceId: string) => {
return deviceIdentities.find(identity => identity.deviceId === deviceId);
}
: undefined,
getDeviceIdentity,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DetailedDevice: React.FC<DeviceProps> = ({
getDeviceIdentity,
isProteusVerified,
}) => {
const getIdentity = getDeviceIdentity ? () => getDeviceIdentity(device.id) : undefined;
const getIdentity = () => getDeviceIdentity?.(device.id);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import {MLSStatuses, WireIdentity} from 'src/script/E2EIdentity';
import {E2EIHandler, MLSStatuses, WireIdentity} from 'src/script/E2EIdentity';
import {t} from 'Util/LocalizerUtil';
import {splitFingerprint} from 'Util/StringUtil';

Expand All @@ -39,6 +39,7 @@ export const MLSDeviceDetails = ({isCurrentDevice, identity, isSelfUser = false}
}

const certificateState = identity?.status ?? MLSStatuses.NOT_ACTIVATED;
const isE2EIEnabled = E2EIHandler.getInstance().isE2EIEnabled();

if (!isSelfUser && certificateState === MLSStatuses.NOT_ACTIVATED) {
return null;
Expand All @@ -58,7 +59,7 @@ export const MLSDeviceDetails = ({isCurrentDevice, identity, isSelfUser = false}
</>
)}

{(isSelfUser || (!isSelfUser && certificateState !== MLSStatuses.NOT_ACTIVATED)) && (
{isE2EIEnabled && (isSelfUser || (!isSelfUser && certificateState !== MLSStatuses.NOT_ACTIVATED)) && (
<E2EICertificateDetails identity={identity} isCurrentDevice={isCurrentDevice} />
)}
</div>
Expand Down

0 comments on commit ef47e2e

Please sign in to comment.