Update selected item color in Pass menu
[ProtonMail-WebClient.git] / packages / pass / hooks / usePassExtensionInstalled.ts
blob1caea645bacf7b395b35b5d867a688c983dc86da
1 import { useEffect, useState } from 'react';
3 import { WorkerMessageType } from '@proton/pass/types';
4 import { sendExtensionMessage } from '@proton/shared/lib/browser/extension';
5 import { APPS } from '@proton/shared/lib/constants';
6 import noop from '@proton/utils/noop';
8 export const usePassExtensionInstalled = (supported: boolean): boolean => {
9     const [installed, setInstalled] = useState(true);
11     useEffect(() => {
12         if (supported) {
13             sendExtensionMessage(
14                 { type: WorkerMessageType.ACCOUNT_PROBE },
15                 { app: APPS.PROTONPASSBROWSEREXTENSION, maxTimeout: 1_000 }
16             )
17                 .then((result) => setInstalled(result?.type === 'success'))
18                 .catch(noop);
19         }
20     }, []);
22     return installed;