mobile: reset session correctly on logout

This commit is contained in:
ammarahm-ed
2023-08-02 13:28:45 +05:00
parent a98cb48c18
commit 968119e5e1
4 changed files with 202 additions and 266 deletions

View File

@@ -17,18 +17,22 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import { Modal, View } from "react-native";
import { db } from "../../common/database";
import { MMKV } from "../../common/database/mmkv";
import BiometricService from "../../services/biometrics";
import {
ToastEvent,
eSendEvent,
eSubscribeEvent
} from "../../services/event-manager";
import { setLoginMessage } from "../../services/message";
import SettingsService from "../../services/settings";
import Sync from "../../services/sync";
import { useThemeColors } from "@notesnook/theme";
import { clearAllStores } from "../../stores";
import { useUserStore } from "../../stores/use-user-store";
import { eLoginSessionExpired, eUserLoggedIn } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
@@ -71,9 +75,12 @@ export const SessionExpired = () => {
try {
await db.user.logout();
await BiometricService.resetCredentials();
SettingsService.set({
introCompleted: true
});
setLoginMessage();
SettingsService.resetSettings();
useUserStore.getState().setUser(null);
useUserStore.getState().setSyncing(false);
MMKV.clearStore();
clearAllStores();
setVisible(false);
} catch (e) {
ToastEvent.show({

View File

@@ -631,6 +631,7 @@ const doAppLoadActions = async () => {
await useMessageStore.getState().setAnnouncement();
if (NewFeature.present()) return;
if (await checkAppUpdateAvailable()) return;
if (!(await db.user.getUser())) {
setLoginMessage();
return;

View File

@@ -16,7 +16,7 @@
"html-to-text": "9.0.5",
"phone": "^3.1.14",
"qclone": "^1.2.0",
"react-native-actions-sheet": "0.9.0-alpha.21",
"react-native-actions-sheet": "0.9.0-alpha.22",
"react-native-check-version": "https://github.com/flexible-agency/react-native-check-version",
"react-native-drax": "^0.10.2",
"react-native-image-zoom-viewer": "^3.0.1",

File diff suppressed because it is too large Load Diff