On account deletion add 'delete content' checkbox (fixes #2384) (#2385)

* On account deletion add 'delete content' checkbox (fixes #2384)

* css

* rename

* i18n
This commit is contained in:
Nutomic 2024-03-05 14:58:08 +01:00 committed by GitHub
parent 79ed590335
commit 2aff64bcdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,6 +108,7 @@ interface SettingsState {
old_password?: string; old_password?: string;
}; };
deleteAccountForm: { deleteAccountForm: {
delete_content?: boolean;
password?: string; password?: string;
}; };
personBlocks: PersonBlockView[]; personBlocks: PersonBlockView[];
@ -1094,6 +1095,25 @@ export class Settings extends Component<any, SettingsState> {
)} )}
className="my-2" className="my-2"
/> />
<div className="input-group mb-3">
<div className="form-check">
<input
id="delete-account-content"
type="checkbox"
className="form-check-input"
onInput={linkEvent(
this,
this.handleDeleteAccountContentChange,
)}
/>
<label
className="form-check-label"
htmlFor="delete-account-content"
>
{I18NextService.i18n.t("delete_account_content")}
</label>
</div>
</div>
<button <button
type="submit" type="submit"
className="btn btn-danger me-4" className="btn btn-danger me-4"
@ -1676,6 +1696,12 @@ export class Settings extends Component<any, SettingsState> {
i.setState({ deleteAccountShowConfirm: !i.state.deleteAccountShowConfirm }); i.setState({ deleteAccountShowConfirm: !i.state.deleteAccountShowConfirm });
} }
handleDeleteAccountContentChange(i: Settings, event: any) {
i.setState(
s => ((s.deleteAccountForm.delete_content = event.target.checked), s),
);
}
handleDeleteAccountPasswordChange(i: Settings, event: any) { handleDeleteAccountPasswordChange(i: Settings, event: any) {
i.setState(s => ((s.deleteAccountForm.password = event.target.value), s)); i.setState(s => ((s.deleteAccountForm.password = event.target.value), s));
} }
@ -1687,8 +1713,7 @@ export class Settings extends Component<any, SettingsState> {
i.setState({ deleteAccountRes: LOADING_REQUEST }); i.setState({ deleteAccountRes: LOADING_REQUEST });
const deleteAccountRes = await HttpService.client.deleteAccount({ const deleteAccountRes = await HttpService.client.deleteAccount({
password, password,
// TODO: promt user weather he wants the content to be deleted delete_content: i.state.deleteAccountForm.delete_content || false,
delete_content: false,
}); });
if (deleteAccountRes.state === "success") { if (deleteAccountRes.state === "success") {
UserService.Instance.logout(); UserService.Instance.logout();