1 import { useCallback } from 'react';
3 import browser from '@proton/pass/lib/globals/browser';
5 /* use PassCore::openSettings and remove this */
6 export const useOpenSettingsTab = () => {
7 return useCallback(async (page?: string) => {
9 const settingsUrl = browser.runtime.getURL('/settings.html');
10 const url = `${settingsUrl}#/${page ?? ''}`;
11 const match = await browser.tabs.query({ url: settingsUrl });
13 await (match.length > 0 && match[0].id
14 ? browser.tabs.update(match[0].id, { active: true, url })
15 : browser.tabs.create({ url }));