mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
Merge pull request #7901 from 01zulfi/web/delete-data-for-not-logged-in-user
web: add delete data option for not logged in user
This commit is contained in:
@@ -94,6 +94,7 @@ import { SyncStatus, useUserStore } from "../stores/use-user-store";
|
||||
import { updateStatusBarColor } from "../utils/colors";
|
||||
import { BETA } from "../utils/constants";
|
||||
import {
|
||||
eAfterSync,
|
||||
eCloseSheet,
|
||||
eEditorReset,
|
||||
eLoginSessionExpired,
|
||||
@@ -332,6 +333,7 @@ const onLogout = async (reason: string) => {
|
||||
SettingsService.resetSettings();
|
||||
useUserStore.getState().setUser(null);
|
||||
useUserStore.getState().setSyncing(false);
|
||||
eSendEvent(eAfterSync);
|
||||
};
|
||||
|
||||
async function checkForShareExtensionLaunchedInBackground() {
|
||||
|
||||
@@ -62,7 +62,11 @@ import SettingsService from "../../services/settings";
|
||||
import Sync from "../../services/sync";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import { useUserStore } from "../../stores/use-user-store";
|
||||
import { eCloseSheet, eOpenRecoveryKeyDialog } from "../../utils/events";
|
||||
import {
|
||||
eAfterSync,
|
||||
eCloseSheet,
|
||||
eOpenRecoveryKeyDialog
|
||||
} from "../../utils/events";
|
||||
import { NotesnookModule } from "../../utils/notesnook-module";
|
||||
import { sleep } from "../../utils/time";
|
||||
import { MFARecoveryCodes, MFASheet } from "./2fa";
|
||||
@@ -72,8 +76,49 @@ import { logoutUser } from "./logout";
|
||||
import { SettingSection } from "./types";
|
||||
import { getTimeLeft } from "./user-section";
|
||||
import { EDITOR_LINE_HEIGHT } from "../../utils/constants";
|
||||
import { MMKV } from "../../common/database/mmkv";
|
||||
import { resetTabStore } from "../editor/tiptap/use-tab-store";
|
||||
import { clearAllStores } from "../../stores";
|
||||
import { refreshAllStores } from "../../stores/create-db-collection-store";
|
||||
|
||||
export const settingsGroups: SettingSection[] = [
|
||||
{
|
||||
id: "account-local",
|
||||
name: strings.account(),
|
||||
useHook: () => useUserStore((state) => state.user),
|
||||
hidden: (current) => !!current,
|
||||
sections: [
|
||||
{
|
||||
id: "delete-data",
|
||||
name: strings.deleteData(),
|
||||
description: strings.deleteAccountDesc(),
|
||||
modifer: () => {
|
||||
presentDialog({
|
||||
title: strings.deleteData(),
|
||||
paragraph: strings.irreverisibleAction(),
|
||||
positiveType: "errorShade",
|
||||
positiveText: "Delete data",
|
||||
positivePress: async () => {
|
||||
await PremiumService.setPremiumStatus();
|
||||
await BiometricService.resetCredentials();
|
||||
MMKV.clearStore();
|
||||
resetTabStore();
|
||||
clearAllStores();
|
||||
Navigation.queueRoutesForUpdate();
|
||||
SettingsService.resetSettings();
|
||||
db.reset();
|
||||
|
||||
setImmediate(() => {
|
||||
refreshAllStores();
|
||||
eSendEvent(eAfterSync);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "account",
|
||||
name: strings.account(),
|
||||
|
||||
@@ -35,6 +35,7 @@ import { EmailChangeDialog } from "../email-change-dialog";
|
||||
import { RecoveryKeyDialog } from "../recovery-key-dialog";
|
||||
import { UserProfile } from "./components/user-profile";
|
||||
import { SettingsGroup } from "./types";
|
||||
import Config from "../../utils/config";
|
||||
|
||||
export const ProfileSettings: SettingsGroup[] = [
|
||||
{
|
||||
@@ -90,6 +91,37 @@ export const ProfileSettings: SettingsGroup[] = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "delete-data-for-not-logged-in-user",
|
||||
title: strings.deleteData(),
|
||||
description: strings.deleteAccountDesc(),
|
||||
keywords: [
|
||||
strings.deleteData(),
|
||||
strings.deleteAccount(),
|
||||
strings.clear()
|
||||
],
|
||||
isHidden: () => Boolean(useUserStore.getState().isLoggedIn),
|
||||
components: [
|
||||
{
|
||||
type: "button",
|
||||
variant: "error",
|
||||
title: strings.deleteData(),
|
||||
action: async () => {
|
||||
const ok = await ConfirmDialog.show({
|
||||
title: strings.deleteData(),
|
||||
message: strings.deleteAccountDesc(),
|
||||
positiveButtonText: strings.yes(),
|
||||
negativeButtonText: strings.no()
|
||||
});
|
||||
if (ok) {
|
||||
Config.clear();
|
||||
await db.reset();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "account-removal",
|
||||
title: strings.deleteAccount(),
|
||||
|
||||
@@ -2129,6 +2129,10 @@ msgstr "Delete collapsed section"
|
||||
msgid "Delete column"
|
||||
msgstr "Delete column"
|
||||
|
||||
#: src/strings.ts:2636
|
||||
msgid "Delete data"
|
||||
msgstr "Delete data"
|
||||
|
||||
#: src/strings.ts:1314
|
||||
msgid "Delete group"
|
||||
msgstr "Delete group"
|
||||
|
||||
@@ -2118,6 +2118,10 @@ msgstr ""
|
||||
msgid "Delete column"
|
||||
msgstr ""
|
||||
|
||||
#: src/strings.ts:2636
|
||||
msgid "Delete data"
|
||||
msgstr ""
|
||||
|
||||
#: src/strings.ts:1314
|
||||
msgid "Delete group"
|
||||
msgstr ""
|
||||
|
||||
@@ -2632,5 +2632,6 @@ Use this if changes from other devices are not appearing on this device. This wi
|
||||
expiryDate: () => t`Expiry date`,
|
||||
exportCsv: () => t`Export CSV`,
|
||||
importCsv: () => t`Import CSV`,
|
||||
noContent: () => t`This note is empty`
|
||||
noContent: () => t`This note is empty`,
|
||||
deleteData: () => t`Delete data`
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user