Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix fetchUser not saving user

ammarahm-ed0edbb3dc0b41
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index f6697ea61..bf0d1f7d3 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -212,7 +212,7 @@ const App = () => {
};
const onEmailVerified = async () => {
- let user = await db.user.fetchUser();
+ let user = await db.user.fetchUser(true);
dispatch({type: Actions.USER, user: user});
if (!user) return;
let message =
@@ -324,7 +324,7 @@ const App = () => {
const setCurrentUser = async () => {
try {
- let user = await db.user.fetchUser();
+ let user = await db.user.getUser(true);
if (user) {
clearMessage(dispatch);
if (!user.isEmailConfirmed) {
diff --git a/apps/mobile/src/components/Premium/PendingDialog.js b/apps/mobile/src/components/Premium/PendingDialog.js
index 52ec2daba..7786106b9 100644
--- a/apps/mobile/src/components/Premium/PendingDialog.js
+++ b/apps/mobile/src/components/Premium/PendingDialog.js
@@ -21,7 +21,7 @@ class PendingDialog extends React.Component {
async open() {
actionSheet.current?.setModalVisible(true);
- let u = await db.user.fetchUser();
+ let u = await db.user.getUser();
this.setState({
user: u && u.Id ? u : null,
});
diff --git a/apps/mobile/src/utils/Storage.js b/apps/mobile/src/utils/Storage.js
index ddccac97e..3baa2f2a9 100644
--- a/apps/mobile/src/utils/Storage.js
+++ b/apps/mobile/src/utils/Storage.js
@@ -19,6 +19,7 @@ async function read(key, isArray = false) {
}
async function write(key, data) {
+ console.log(key, data);
return await MMKV.setItem(
key,
typeof data === 'string' ? data : JSON.stringify(data),
@@ -56,9 +57,8 @@ function encrypt(password, data) {
return Sodium.encrypt(password, data).then((result) => result);
}
-
function decrypt(password, data) {
- return Sodium.decrypt(password,data).then((result) => result);
+ return Sodium.decrypt(password, data).then((result) => result);
}
let CRYPT_CONFIG = Platform.select({
@@ -85,7 +85,7 @@ async function deriveCryptoKey(name, data) {
credentials.key,
CRYPT_CONFIG,
);
- console.log(credentials.key)
+ console.log(credentials.key);
return credentials.key;
} catch (e) {
console.log(e);
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index a3148ba76..eb914bdd0 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -12,6 +12,7 @@ import {scrollRef} from '../../utils';
import {db} from '../../utils/DB';
import {eOnLoadNote, eScrollEvent} from '../../utils/Events';
import {tabBarRef} from '../../utils/Refs';
+import Storage from '../../utils/storage';
export const Home = ({route, navigation}) => {
const [state, dispatch] = useTracked();
@@ -83,7 +84,10 @@ export const Home = ({route, navigation}) => {
});
};
- const _onPressBottomButton = (event) => {
+ const _onPressBottomButton = async (event) => {
+ console.log(await Storage.read("token"));
+
+ return;
if (!DDS.isLargeTablet()) {
tabBarRef.current?.goToPage(1);
} else {