mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-03-20 15:41:40 -04:00
Linting refactor (#541)
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { DISABLED_SITES_KEY } from '../../contentScript/Popup';
|
||||
|
||||
interface PopupSettings {
|
||||
/**
|
||||
* Popup settings type.
|
||||
*/
|
||||
type PopupSettings = {
|
||||
disabledUrls: string[];
|
||||
currentUrl: string;
|
||||
isEnabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings page component.
|
||||
*/
|
||||
const Settings: React.FC = () => {
|
||||
const [settings, setSettings] = useState<PopupSettings>({
|
||||
disabledUrls: [],
|
||||
@@ -14,17 +20,19 @@ const Settings: React.FC = () => {
|
||||
isEnabled: true
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
loadSettings();
|
||||
}, []);
|
||||
|
||||
const getCurrentTab = async () => {
|
||||
/**
|
||||
* Get current tab in browser.
|
||||
*/
|
||||
const getCurrentTab = async () : Promise<chrome.tabs.Tab> => {
|
||||
const queryOptions = { active: true, currentWindow: true };
|
||||
const [tab] = await chrome.tabs.query(queryOptions);
|
||||
return tab;
|
||||
};
|
||||
|
||||
const loadSettings = async () => {
|
||||
/**
|
||||
* Load settings.
|
||||
*/
|
||||
const loadSettings = useCallback(async () : Promise<void> => {
|
||||
const tab = await getCurrentTab();
|
||||
const currentUrl = new URL(tab.url || '').hostname;
|
||||
|
||||
@@ -37,9 +45,16 @@ const Settings: React.FC = () => {
|
||||
isEnabled: !disabledUrls.includes(currentUrl)
|
||||
});
|
||||
});
|
||||
};
|
||||
}, []); // No dependencies needed since it only uses external APIs
|
||||
|
||||
const toggleCurrentSite = async () => {
|
||||
useEffect(() => {
|
||||
loadSettings();
|
||||
}, [loadSettings]);
|
||||
|
||||
/**
|
||||
* Toggle current site.
|
||||
*/
|
||||
const toggleCurrentSite = async () : Promise<void> => {
|
||||
const { currentUrl, disabledUrls, isEnabled } = settings;
|
||||
let newDisabledUrls = [...disabledUrls];
|
||||
|
||||
@@ -59,8 +74,10 @@ const Settings: React.FC = () => {
|
||||
}));
|
||||
};
|
||||
|
||||
const resetSettings = async () => {
|
||||
// Fix: Use DISABLED_SITES_KEY as the key name here too
|
||||
/**
|
||||
* Reset settings.
|
||||
*/
|
||||
const resetSettings = async () : Promise<void> => {
|
||||
const storageData = { [DISABLED_SITES_KEY]: [] };
|
||||
await chrome.storage.local.set(storageData);
|
||||
|
||||
@@ -79,11 +96,11 @@ const Settings: React.FC = () => {
|
||||
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<div className="text-gray-500 dark:text-gray-400 space-y-2 mb-4">
|
||||
<p className="text-sm">
|
||||
<div className="text-gray-500 dark:text-gray-400 space-y-2 mb-4">
|
||||
<p className="text-sm">
|
||||
You can enable or disable the autofill popup per site.
|
||||
</p>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
||||
<div>
|
||||
<p className="text-sm font-medium text-gray-900 dark:text-white">{settings.currentUrl}</p>
|
||||
|
||||
@@ -233,8 +233,10 @@ function triggerInputEvents(element: HTMLInputElement) : void {
|
||||
// Create an overlay div that will show the highlight effect
|
||||
const overlay = document.createElement('div');
|
||||
|
||||
// Initial positioning
|
||||
const updatePosition = () => {
|
||||
/**
|
||||
* Update position of the overlay.
|
||||
*/
|
||||
const updatePosition = () : void => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
overlay.style.cssText = `
|
||||
position: fixed;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Credential SQLite database type.
|
||||
*/
|
||||
export type Credential = {
|
||||
Id: string;
|
||||
Username: string;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Encryption key SQLite database type.
|
||||
*/
|
||||
export type EncryptionKey = {
|
||||
Id: string;
|
||||
PublicKey: string;
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
/**
|
||||
* Email attachment type.
|
||||
*/
|
||||
export type Attachment = {
|
||||
/** The ID of the attachment */
|
||||
id: number;
|
||||
|
||||
/** The ID of the email the attachment belongs to */
|
||||
emailId: number;
|
||||
|
||||
/** The filename of the attachment */
|
||||
filename: string;
|
||||
|
||||
/** The MIME type of the attachment */
|
||||
mimeType: string;
|
||||
|
||||
/** The size of the attachment in bytes */
|
||||
filesize: number;
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
/**
|
||||
* Login request type.
|
||||
*/
|
||||
export type LoginRequest = {
|
||||
username: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login response type.
|
||||
*/
|
||||
export type LoginResponse = {
|
||||
salt: string;
|
||||
serverEphemeral: string;
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { MailboxEmail } from "./MailboxEmail";
|
||||
|
||||
/**
|
||||
* Mailbox bulk request type.
|
||||
*/
|
||||
export type MailboxBulkRequest = {
|
||||
addresses: string[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mailbox bulk response type.
|
||||
*/
|
||||
export type MailboxBulkResponse = {
|
||||
addresses: string[];
|
||||
currentPage: number;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Validate login request type.
|
||||
*/
|
||||
export type ValidateLoginRequest = {
|
||||
username: string;
|
||||
rememberMe: boolean;
|
||||
@@ -5,6 +8,9 @@ export type ValidateLoginRequest = {
|
||||
clientSessionProof: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate login request type for 2FA.
|
||||
*/
|
||||
export type ValidateLoginRequest2Fa = {
|
||||
username: string;
|
||||
code2Fa: number;
|
||||
@@ -13,6 +19,9 @@ export type ValidateLoginRequest2Fa = {
|
||||
clientSessionProof: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate login response type.
|
||||
*/
|
||||
export type ValidateLoginResponse = {
|
||||
requiresTwoFactor: boolean;
|
||||
token?: {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Vault type.
|
||||
*/
|
||||
export type Vault = {
|
||||
blob: string;
|
||||
createdAt: string;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Vault } from "./Vault";
|
||||
|
||||
/**
|
||||
* Vault response type.
|
||||
*/
|
||||
export type VaultResponse = {
|
||||
status: number;
|
||||
vault: Vault;
|
||||
|
||||
Reference in New Issue
Block a user