From d279c4029b85c47b0676a292012f9be8a8ff106f Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 17 Mar 2026 15:48:59 +0100 Subject: [PATCH] add delete functionality to PerMessageProfileEditor and integrate into overview; adjust layout and styles --- .../Profiles/PerMessageProfileEditor.tsx | 46 ++++++++++--------- .../Profiles/PerMessageProfileOverview.tsx | 33 +++++++++++-- .../settings/Profiles/ProfilesPage.tsx | 1 - 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/app/features/settings/Profiles/PerMessageProfileEditor.tsx b/src/app/features/settings/Profiles/PerMessageProfileEditor.tsx index c91328a5..08999785 100644 --- a/src/app/features/settings/Profiles/PerMessageProfileEditor.tsx +++ b/src/app/features/settings/Profiles/PerMessageProfileEditor.tsx @@ -21,6 +21,7 @@ type PerMessageProfileEditorProps = { avatarMxcUrl?: string; displayName?: string; onChange?: (profile: { id: string; name: string; avatarUrl?: string }) => void; + onDelete?: (profileId: string) => void; }; export function PerMessageProfileEditor({ @@ -29,6 +30,7 @@ export function PerMessageProfileEditor({ avatarMxcUrl, displayName, onChange, + onDelete, }: Readonly) { const useAuthentication = useMediaAuthentication(); const [currentDisplayName, setCurrentDisplayName] = useState(displayName ?? ''); @@ -97,6 +99,7 @@ export function PerMessageProfileEditor({ const handleDelete = useCallback(() => { deletePerMessageProfile(mx, profileId).then(() => { setCurrentDisplayName(''); + if (onDelete) onDelete(profileId); }); }, [mx, profileId]); @@ -124,8 +127,8 @@ export function PerMessageProfileEditor({ style={{ width: '100%', minWidth: 500, - minHeight: 200, - padding: config.space.S600, + minHeight: 100, + maxHeight: 200, boxSizing: 'border-box', display: 'flex', flexDirection: 'row', @@ -136,27 +139,26 @@ export function PerMessageProfileEditor({ }} > Profile ID: {profileId} - {/* Linke Spalte: Avatar + Upload */} Upload - {/* Upload-Bereich falls aktiv */} {uploadAtom && ( )} - {/* Mittlere Spalte: Display Name Input */} @@ -235,14 +235,15 @@ export function PerMessageProfileEditor({ flex: 1, minWidth: 0, width: '100%', - maxWidth: 'clamp(120px, 40vw, 320px)', + maxWidth: 'clamp(200px, 60vw, 480px)', paddingRight: config.space.S200, fontSize: 16, - height: 36, + height: 50, }} placeholder="Display name" readOnly={changingDisplayName || disableSetDisplayname} - aria-label="Display name" + aria-label={`Display name for ${profileId}`} + title={`Display name for ${profileId}`} after={ hasChanges && !changingDisplayName && ( @@ -253,6 +254,7 @@ export function PerMessageProfileEditor({ radii="300" variant="Secondary" aria-label="Reset display name" + title="Reset display name" > @@ -266,7 +268,7 @@ export function PerMessageProfileEditor({ alignItems="Center" justifyContent="Center" style={{ minWidth: 120, maxWidth: 140, flexShrink: 0, height: '100%' }} - aria-label="Save button area" + aria-label={`Save button area for ${profileId}`} > @@ -293,13 +296,14 @@ export function PerMessageProfileEditor({ fill="None" style={{ minWidth: 120, - height: 44, + height: 'clamp(30px, 6vw, 50px)', marginTop: config.space.S100, display: 'flex', alignItems: 'center', justifyContent: 'center', }} - aria-label="Delete profile" + aria-label={`Delete profile ${profileId}`} + title={`Delete profile ${profileId}`} > Delete diff --git a/src/app/features/settings/Profiles/PerMessageProfileOverview.tsx b/src/app/features/settings/Profiles/PerMessageProfileOverview.tsx index 879a6dbc..5f4a2061 100644 --- a/src/app/features/settings/Profiles/PerMessageProfileOverview.tsx +++ b/src/app/features/settings/Profiles/PerMessageProfileOverview.tsx @@ -1,7 +1,11 @@ import { useMatrixClient } from '$hooks/useMatrixClient'; -import { getAllPerMessageProfiles, PerMessageProfile } from '$hooks/usePerMessageProfile'; +import { + addOrUpdatePerMessageProfile, + getAllPerMessageProfiles, + PerMessageProfile, +} from '$hooks/usePerMessageProfile'; import { useEffect, useState } from 'react'; -import { Box } from 'folds'; +import { Box, Button, Text } from 'folds'; import { PerMessageProfileEditor } from './PerMessageProfileEditor'; /** @@ -20,14 +24,37 @@ export function PerMessageProfileOverview() { fetchProfiles(); }, [mx]); + // Handler to remove a profile from the list after deletion + const handleDelete = (profileId: string) => { + setProfiles((prevProfiles) => prevProfiles.filter((profile) => profile.id !== profileId)); + }; + return ( - + + + Per-Message Profiles + + {profiles.map((profile) => ( ))} diff --git a/src/app/features/settings/Profiles/ProfilesPage.tsx b/src/app/features/settings/Profiles/ProfilesPage.tsx index 56eff745..3b26cd8d 100644 --- a/src/app/features/settings/Profiles/ProfilesPage.tsx +++ b/src/app/features/settings/Profiles/ProfilesPage.tsx @@ -37,7 +37,6 @@ export function PerMessageProfilePage({ requestClose }: PerMessageProfilePagePro direction="Column" shrink="No" > - Per-Message Profiles