From 13dd8fcc0696d18e2af0f8eed234ff64660f402e Mon Sep 17 00:00:00 2001 From: Ginger Date: Mon, 6 Oct 2025 14:18:41 -0400 Subject: [PATCH] Allow account data to be deleted if the homeserver supports it --- .../settings/developer-tools/DevelopTools.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/app/features/settings/developer-tools/DevelopTools.tsx b/src/app/features/settings/developer-tools/DevelopTools.tsx index 4ac58f46..01e6e6a4 100644 --- a/src/app/features/settings/developer-tools/DevelopTools.tsx +++ b/src/app/features/settings/developer-tools/DevelopTools.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useState } from 'react'; import { Box, Text, IconButton, Icon, Icons, Scroll, Switch, Button } from 'folds'; import { AccountDataEvents } from 'matrix-js-sdk'; +import { Feature, ServerSupport } from 'matrix-js-sdk/lib/feature'; import { Page, PageContent, PageHeader } from '../../../components/page'; import { SequenceCard } from '../../../components/sequence-card'; import { SequenceCardStyle } from '../styles.css'; @@ -34,13 +35,16 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { const [accountDataTypes, setAccountDataKeys] = useState(() => Array.from(mx.store.accountData.keys()) ); - + const accountDataDeletionSupported = + (mx.canSupport.get(Feature.AccountDataDeletion) ?? ServerSupport.Unsupported) !== + ServerSupport.Unsupported; useAccountDataCallback( mx, useCallback(() => { setAccountDataKeys(Array.from(mx.store.accountData.keys())); }, [mx]) ); + const [extendedProfile, refreshExtendedProfile] = useExtendedProfile(userId); const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools'); @@ -55,6 +59,13 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { [mx] ); + const deleteAccountData: AccountDataDeleteCallback = useCallback( + async (type) => { + await mx.deleteAccountData(type as keyof AccountDataEvents); + }, + [mx] + ); + const submitProfileField: AccountDataSubmitCallback = useCallback( async (type, content) => { await mx.setExtendedProfileProperty(type, content); @@ -78,8 +89,13 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) { return ( );