mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-03-18 22:57:01 -04:00
Refactor chrome specific API, set font-size to 75% for all browsers (#581)
This commit is contained in:
@@ -7,7 +7,7 @@ import { BoolResponse } from '../../utils/types/messaging/BoolResponse';
|
||||
export function handleOpenPopup() : Promise<BoolResponse> {
|
||||
return (async () : Promise<BoolResponse> => {
|
||||
browser.windows.create({
|
||||
url: browser.runtime.getURL('/popup.html?mode=inline_unlock'),
|
||||
url: browser.runtime.getURL('/popup.html?mode=inline_unlock&expanded=true'),
|
||||
type: 'popup',
|
||||
width: 400,
|
||||
height: 600,
|
||||
@@ -23,7 +23,7 @@ export function handleOpenPopup() : Promise<BoolResponse> {
|
||||
export function handlePopupWithCredential(message: any) : Promise<BoolResponse> {
|
||||
return (async () : Promise<BoolResponse> => {
|
||||
browser.windows.create({
|
||||
url: browser.runtime.getURL(`/popup.html#/credentials/${message.credentialId}`),
|
||||
url: browser.runtime.getURL(`/popup.html?expanded=true#/credentials/${message.credentialId}`),
|
||||
type: 'popup',
|
||||
width: 400,
|
||||
height: 600,
|
||||
|
||||
@@ -26,8 +26,8 @@ export const EmailPreview: React.FC<EmailPreviewProps> = ({ email }) => {
|
||||
*/
|
||||
const isPublicDomain = async (emailAddress: string): Promise<boolean> => {
|
||||
// Get metadata from storage
|
||||
const storageResult = await chrome.storage.session.get(['publicEmailDomains']);
|
||||
return storageResult.publicEmailDomains.some(domain => emailAddress.toLowerCase().endsWith(domain));
|
||||
const publicEmailDomains = await storage.getItem('session:publicEmailDomains') as string[] ?? [];
|
||||
return publicEmailDomains.some(domain => emailAddress.toLowerCase().endsWith(domain));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -6,8 +6,16 @@
|
||||
<title>AliasVault</title>
|
||||
<link href="~/assets/tailwind.css" rel="stylesheet" />
|
||||
<meta name="manifest.type" content="browser_action" />
|
||||
<script>
|
||||
// Check if expanded=true is in the URL, which means the popup was opened in expanded mode with unlimited width.
|
||||
// If not, set the width to 350px to force the default popup to a fixed width.
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
if (!urlParams.get('expanded')) {
|
||||
document.documentElement.classList.add('max-w-[350px]');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body class="bg-white dark:bg-gray-900">
|
||||
<body class="bg-white dark:bg-gray-900" style="font-size: 75%;">
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./main.tsx"></script>
|
||||
</body>
|
||||
|
||||
@@ -18,15 +18,15 @@ const CredentialDetails: React.FC = () => {
|
||||
const { setIsInitialLoading } = useLoading();
|
||||
|
||||
/**
|
||||
* Check if the current page is a popup.
|
||||
* Check if the current page is an expanded popup.
|
||||
*/
|
||||
const isPopup = () : boolean => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.get('popup') === 'true';
|
||||
return urlParams.get('expanded') === 'true';
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the credential details in a new popup.
|
||||
* Open the credential details in a new expanded popup.
|
||||
*/
|
||||
const openInNewPopup = () : void => {
|
||||
const width = 380;
|
||||
@@ -35,7 +35,7 @@ const CredentialDetails: React.FC = () => {
|
||||
const top = window.screen.height / 2 - height / 2;
|
||||
|
||||
window.open(
|
||||
`popup.html?popup=true#/credentials/${id}`,
|
||||
`popup.html?expanded=true#/credentials/${id}`,
|
||||
'CredentialDetails',
|
||||
`width=${width},height=${height},left=${left},top=${top},popup=true`
|
||||
);
|
||||
|
||||
@@ -81,15 +81,15 @@ const EmailDetails: React.FC = () => {
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the current page is a popup.
|
||||
* Check if the current page is an expanded popup.
|
||||
*/
|
||||
const isPopup = () : boolean => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.get('popup') === 'true';
|
||||
return urlParams.get('expanded') === 'true';
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the credential details in a new popup.
|
||||
* Open the credential details in a new expanded popup.
|
||||
*/
|
||||
const openInNewPopup = () : void => {
|
||||
const width = 800;
|
||||
@@ -98,7 +98,7 @@ const EmailDetails: React.FC = () => {
|
||||
const top = window.screen.height / 2 - height / 2;
|
||||
|
||||
window.open(
|
||||
`popup.html?popup=true#/emails/${id}`,
|
||||
`popup.html?expanded=true#/emails/${id}`,
|
||||
'EmailDetails',
|
||||
`width=${width},height=${height},left=${left},top=${top},popup=true`
|
||||
);
|
||||
|
||||
@@ -287,26 +287,24 @@ export class WebApiService {
|
||||
* Get the current access token from storage.
|
||||
*/
|
||||
private async getAccessToken(): Promise<string | null> {
|
||||
const token = await chrome.storage.local.get('accessToken');
|
||||
return token.accessToken ?? null;
|
||||
const token = await storage.getItem('local:accessToken') as string;
|
||||
return token ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current refresh token from storage.
|
||||
*/
|
||||
private async getRefreshToken(): Promise<string | null> {
|
||||
const token = await chrome.storage.local.get('refreshToken');
|
||||
return token.refreshToken ?? null;
|
||||
const token = await storage.getItem('local:refreshToken') as string;
|
||||
return token ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update both access and refresh tokens in storage.
|
||||
*/
|
||||
private async updateTokens(accessToken: string, refreshToken: string): Promise<void> {
|
||||
await chrome.storage.local.set({
|
||||
accessToken,
|
||||
refreshToken
|
||||
});
|
||||
await storage.setItem('local:accessToken', accessToken);
|
||||
await storage.setItem('local:refreshToken', refreshToken);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user