diff --git a/frontend/src/chat/profileDialog.ts b/frontend/src/chat/profileDialog.ts index f980375..a5007fb 100644 --- a/frontend/src/chat/profileDialog.ts +++ b/frontend/src/chat/profileDialog.ts @@ -11,9 +11,12 @@ import type { UserProfile } from "../core/types"; import { showError, showSuccess } from "../utils/notification"; import { formatTime } from "../utils/utils"; import defaultAvatar from "../resources/images/default-avatar.png"; +import type { Tabs } from "mdui/components/tabs"; +import type { Dialog } from "mdui/components/dialog"; +import type { TextField } from "mdui/components/text-field"; -let dialog = document.getElementById("user-profile-dialog")!; +let dialog = document.getElementById("user-profile-dialog") as Dialog; let currentProfile: UserProfile | null = null; let isOwnProfile: boolean = false; @@ -34,13 +37,6 @@ function bindEvents(): void { editBioBtn?.addEventListener('click', () => startEditBio()); saveBioBtn?.addEventListener('click', () => saveBio()); cancelBioBtn?.addEventListener('click', () => cancelEditBio()); - - // Keyboard shortcuts - document.addEventListener('keydown', (e) => { - if (e.key === 'Escape' && dialog?.getAttribute('open') !== null) { - hide(); - } - }); } /** @@ -63,7 +59,7 @@ export async function show(username: string): Promise { currentProfile = profile; isOwnProfile = profile.username === currentUser?.username; populateDialog(profile); - (dialog as any).open = true; + dialog.open = true; } catch (error) { showError('Failed to load user profile'); @@ -108,7 +104,7 @@ function populateDialog(profile: UserProfile): void { // Bio const bioDisplay = dialog.querySelector('.bio-display') as HTMLElement; - const bioEdit = dialog.querySelector('#bio-edit-field') as any; + const bioEdit = dialog.querySelector('#bio-edit-field') as TextField; if (profile.bio) { bioDisplay.textContent = profile.bio; @@ -136,7 +132,7 @@ function startEditBio(): void { if (!dialog) return; const bioDisplay = dialog.querySelector('.bio-display') as HTMLElement; - const bioEdit = dialog.querySelector('#bio-edit-field') as any; + const bioEdit = dialog.querySelector('#bio-edit-field') as TextField; const bioActions = dialog.querySelector('.bio-actions') as HTMLElement; const editBioBtn = dialog.querySelector('#edit-bio-btn') as HTMLElement; @@ -158,7 +154,7 @@ function startEditBio(): void { export async function saveBio(): Promise { if (!dialog || !currentProfile) return; - const bioEdit = dialog.querySelector('#bio-edit-field') as any; + const bioEdit = dialog.querySelector('#bio-edit-field') as TextField; const newBio = bioEdit?.value?.trim() || ''; try { @@ -195,7 +191,7 @@ function cancelEditBio(): void { if (!dialog) return; const bioDisplay = dialog.querySelector('.bio-display') as HTMLElement; - const bioEdit = dialog.querySelector('#bio-edit-field') as any; + const bioEdit = dialog.querySelector('#bio-edit-field') as TextField; const bioActions = dialog.querySelector('.bio-actions') as HTMLElement; const editBioBtn = dialog.querySelector('#edit-bio-btn') as HTMLElement; @@ -214,9 +210,7 @@ function cancelEditBio(): void { * Hides the dialog */ export function hide(): void { - if (dialog) { - (dialog as any).open = false; - } + dialog.open = false; currentProfile = null; isOwnProfile = false; } diff --git a/frontend/src/userPanel/profile/editor.ts b/frontend/src/userPanel/profile/editor.ts index e1d81df..de4dd7d 100644 --- a/frontend/src/userPanel/profile/editor.ts +++ b/frontend/src/userPanel/profile/editor.ts @@ -111,8 +111,8 @@ function setupFormHandler(): void { // Get DOM elements profileForm = document.getElementById('profile-form')!; - nicknameField = document.getElementById('username-field') as any; - descriptionField = document.getElementById('description-field') as any; + nicknameField = document.getElementById('username-field') as TextField; + descriptionField = document.getElementById('description-field') as TextField; profileForm.addEventListener('submit', handleFormSubmission); diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 4f5edc2..9f84047 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -1,25 +1,22 @@ { - "compilerOptions": { - "target": "ES2022", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2022", "DOM", "DOM.Iterable"], - "skipLibCheck": true, + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "skipLibCheck": true, - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "moduleDetection": "force", - "noEmit": true, + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "erasableSyntaxOnly": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["src"] -} + /* Linting */ + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} \ No newline at end of file