diff --git a/browser-extensions/chrome/src/app/pages/Settings.tsx b/browser-extensions/chrome/src/app/pages/Settings.tsx index c624ae11..bdfee15e 100644 --- a/browser-extensions/chrome/src/app/pages/Settings.tsx +++ b/browser-extensions/chrome/src/app/pages/Settings.tsx @@ -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({ 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 => { 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 => { 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 => { 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 => { const storageData = { [DISABLED_SITES_KEY]: [] }; await chrome.storage.local.set(storageData); @@ -79,11 +96,11 @@ const Settings: React.FC = () => {
-
-

+

+

You can enable or disable the autofill popup per site. -

-
+

+

{settings.currentUrl}

diff --git a/browser-extensions/chrome/src/contentScript/Form.ts b/browser-extensions/chrome/src/contentScript/Form.ts index d645e81a..906b4564 100644 --- a/browser-extensions/chrome/src/contentScript/Form.ts +++ b/browser-extensions/chrome/src/contentScript/Form.ts @@ -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; diff --git a/browser-extensions/chrome/src/shared/types/Credential.ts b/browser-extensions/chrome/src/shared/types/Credential.ts index c896dba2..733d4ab9 100644 --- a/browser-extensions/chrome/src/shared/types/Credential.ts +++ b/browser-extensions/chrome/src/shared/types/Credential.ts @@ -1,3 +1,6 @@ +/** + * Credential SQLite database type. + */ export type Credential = { Id: string; Username: string; diff --git a/browser-extensions/chrome/src/shared/types/EncryptionKey.ts b/browser-extensions/chrome/src/shared/types/EncryptionKey.ts index 39b84798..7dc64d60 100644 --- a/browser-extensions/chrome/src/shared/types/EncryptionKey.ts +++ b/browser-extensions/chrome/src/shared/types/EncryptionKey.ts @@ -1,3 +1,6 @@ +/** + * Encryption key SQLite database type. + */ export type EncryptionKey = { Id: string; PublicKey: string; diff --git a/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts b/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts index 7d3736aa..cd74065f 100644 --- a/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts +++ b/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts @@ -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; } \ No newline at end of file diff --git a/browser-extensions/chrome/src/shared/types/webapi/Login.ts b/browser-extensions/chrome/src/shared/types/webapi/Login.ts index bb48c3cd..40a0822d 100644 --- a/browser-extensions/chrome/src/shared/types/webapi/Login.ts +++ b/browser-extensions/chrome/src/shared/types/webapi/Login.ts @@ -1,7 +1,13 @@ +/** + * Login request type. + */ export type LoginRequest = { username: string; } +/** + * Login response type. + */ export type LoginResponse = { salt: string; serverEphemeral: string; diff --git a/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts b/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts index 9d8c6315..775b8c56 100644 --- a/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts +++ b/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts @@ -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; diff --git a/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts b/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts index 77c655f2..e64eaf21 100644 --- a/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts +++ b/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts @@ -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?: { diff --git a/browser-extensions/chrome/src/shared/types/webapi/Vault.ts b/browser-extensions/chrome/src/shared/types/webapi/Vault.ts index f06feaa8..bb6f6eeb 100644 --- a/browser-extensions/chrome/src/shared/types/webapi/Vault.ts +++ b/browser-extensions/chrome/src/shared/types/webapi/Vault.ts @@ -1,3 +1,6 @@ +/** + * Vault type. + */ export type Vault = { blob: string; createdAt: string; diff --git a/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts b/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts index 80a255b2..06207aff 100644 --- a/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts +++ b/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts @@ -1,5 +1,8 @@ import { Vault } from "./Vault"; +/** + * Vault response type. + */ export type VaultResponse = { status: number; vault: Vault;