mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
Allow account data to be deleted if the homeserver supports it
This commit is contained in:
parent
205ea1655a
commit
13dd8fcc06
1 changed files with 18 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import { Box, Text, IconButton, Icon, Icons, Scroll, Switch, Button } from 'folds';
|
import { Box, Text, IconButton, Icon, Icons, Scroll, Switch, Button } from 'folds';
|
||||||
import { AccountDataEvents } from 'matrix-js-sdk';
|
import { AccountDataEvents } from 'matrix-js-sdk';
|
||||||
|
import { Feature, ServerSupport } from 'matrix-js-sdk/lib/feature';
|
||||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||||
import { SequenceCard } from '../../../components/sequence-card';
|
import { SequenceCard } from '../../../components/sequence-card';
|
||||||
import { SequenceCardStyle } from '../styles.css';
|
import { SequenceCardStyle } from '../styles.css';
|
||||||
|
|
@ -34,13 +35,16 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||||
const [accountDataTypes, setAccountDataKeys] = useState(() =>
|
const [accountDataTypes, setAccountDataKeys] = useState(() =>
|
||||||
Array.from(mx.store.accountData.keys())
|
Array.from(mx.store.accountData.keys())
|
||||||
);
|
);
|
||||||
|
const accountDataDeletionSupported =
|
||||||
|
(mx.canSupport.get(Feature.AccountDataDeletion) ?? ServerSupport.Unsupported) !==
|
||||||
|
ServerSupport.Unsupported;
|
||||||
useAccountDataCallback(
|
useAccountDataCallback(
|
||||||
mx,
|
mx,
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
setAccountDataKeys(Array.from(mx.store.accountData.keys()));
|
setAccountDataKeys(Array.from(mx.store.accountData.keys()));
|
||||||
}, [mx])
|
}, [mx])
|
||||||
);
|
);
|
||||||
|
|
||||||
const [extendedProfile, refreshExtendedProfile] = useExtendedProfile(userId);
|
const [extendedProfile, refreshExtendedProfile] = useExtendedProfile(userId);
|
||||||
|
|
||||||
const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
||||||
|
|
@ -55,6 +59,13 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||||
[mx]
|
[mx]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const deleteAccountData: AccountDataDeleteCallback = useCallback(
|
||||||
|
async (type) => {
|
||||||
|
await mx.deleteAccountData(type as keyof AccountDataEvents);
|
||||||
|
},
|
||||||
|
[mx]
|
||||||
|
);
|
||||||
|
|
||||||
const submitProfileField: AccountDataSubmitCallback = useCallback(
|
const submitProfileField: AccountDataSubmitCallback = useCallback(
|
||||||
async (type, content) => {
|
async (type, content) => {
|
||||||
await mx.setExtendedProfileProperty(type, content);
|
await mx.setExtendedProfileProperty(type, content);
|
||||||
|
|
@ -78,8 +89,13 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||||
return (
|
return (
|
||||||
<AccountDataEditor
|
<AccountDataEditor
|
||||||
type={page.type ?? undefined}
|
type={page.type ?? undefined}
|
||||||
content={page.type ? mx.getAccountData(page.type as keyof AccountDataEvents)?.getContent() : undefined}
|
content={
|
||||||
|
page.type
|
||||||
|
? mx.getAccountData(page.type as keyof AccountDataEvents)?.getContent()
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
submitChange={submitAccountData}
|
submitChange={submitAccountData}
|
||||||
|
submitDelete={accountDataDeletionSupported ? deleteAccountData : undefined}
|
||||||
requestClose={handleClose}
|
requestClose={handleClose}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue