Skip to content

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

add react-native-mmkv-storage

ammarahm-edf72295e39aa2
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 9a3c5972c..58d1503ee 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -37,7 +37,7 @@ import {w} from './src/utils/utils';
import Editor from './src/views/Editor';
import Animated, {Easing} from 'react-native-reanimated';
import {useForceUpdate} from './src/views/ListsEditor';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import {defaultState} from './src/provider/defaultState';
import {EditorPosition} from './src/utils/animations';
export const DDS = new DeviceDetectionService();
@@ -167,12 +167,12 @@ const App = () => {
async function updateAppTheme(colors = colors) {
let newColors = await getColorScheme(colors);
- let s = await FastStorage.getString('settings');
+ let s = await MMKV.getString('settings');
if (typeof s !== 'string') {
s = defaultState.settings;
s = JSON.stringify(s);
- await FastStorage.setString('settings', s);
+ await MMKV.setString('settings', s);
dispatch({type: ACTIONS.SETTINGS, s});
} else {
s = JSON.parse(s);
diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js
index bbbdaefdf..a39904780 100755
--- a/apps/mobile/src/common/common.js
+++ b/apps/mobile/src/common/common.js
@@ -1,5 +1,5 @@
import {Dimensions, PixelRatio, StatusBar, Platform} from 'react-native';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import {
eSendEvent,
eSubscribeEvent,
@@ -187,18 +187,18 @@ export function setColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
}
export async function getColorScheme() {
- let accentColor = await FastStorage.getString('accentColor');
- let t = await FastStorage.getString('theme');
+ let accentColor = await MMKV.getString('accentColor');
+ let t = await MMKV.getString('theme');
if (typeof accentColor !== 'string') {
- FastStorage.setString('accentColor', '#0560FF');
+ MMKV.setString('accentColor', '#0560FF');
setAccentColor('#0560FF');
} else {
setAccentColor(accentColor);
}
if (typeof t !== 'string') {
- FastStorage.setString('theme', JSON.stringify({night: false}));
+ MMKV.setString('theme', JSON.stringify({night: false}));
setColorScheme(COLOR_SCHEME_LIGHT);
} else {
let themeToSet = JSON.parse(t);
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 09ec49af1..bb9a14188 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -9,7 +9,7 @@ import {
Platform,
ToastAndroid,
} from 'react-native';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {db, DDS} from '../../../App';
import {
@@ -283,10 +283,10 @@ export const ActionSheetComponent = ({
icon: 'theme-light-dark',
func: () => {
if (!colors.night) {
- FastStorage.setString('theme', JSON.stringify({night: true}));
+ MMKV.setString('theme', JSON.stringify({night: true}));
changeColorScheme(COLOR_SCHEME_DARK);
} else {
- FastStorage.setString('theme', JSON.stringify({night: false}));
+ MMKV.setString('theme', JSON.stringify({night: false}));
changeColorScheme(COLOR_SCHEME_LIGHT);
}
},
diff --git a/apps/mobile/src/components/EditorMenu/index.js b/apps/mobile/src/components/EditorMenu/index.js
index d9a350ba1..11dd874ec 100644
--- a/apps/mobile/src/components/EditorMenu/index.js
+++ b/apps/mobile/src/components/EditorMenu/index.js
@@ -9,7 +9,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import {TextInput} from 'react-native-gesture-handler';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {
@@ -326,13 +326,13 @@ export const EditorMenu = ({updateProps = () => {}, timestamp}) => {
icon: 'moon',
func: () => {
if (!colors.night) {
- FastStorage.setString(
+ MMKV.setString(
'theme',
JSON.stringify(COLOR_SCHEME_DARK),
);
changeColorScheme(COLOR_SCHEME_DARK);
} else {
- FastStorage.setString(
+ MMKV.setString(
'theme',
JSON.stringify(COLOR_SCHEME_LIGHT),
);
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index 296452e3b..86e75341b 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -8,7 +8,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {DDS, db} from '../../../App';
import {
@@ -96,10 +96,10 @@ export const Menu = ({
icon: 'theme-light-dark',
func: () => {
if (!colors.night) {
- FastStorage.setString('theme', JSON.stringify({night: true}));
+ MMKV.setString('theme', JSON.stringify({night: true}));
changeColorScheme(COLOR_SCHEME_DARK);
} else {
- FastStorage.setString('theme', JSON.stringify({night: false}));
+ MMKV.setString('theme', JSON.stringify({night: false}));
changeColorScheme(COLOR_SCHEME_LIGHT);
}
diff --git a/apps/mobile/src/utils/storage.js b/apps/mobile/src/utils/storage.js
index 71a49e076..03a106245 100644
--- a/apps/mobile/src/utils/storage.js
+++ b/apps/mobile/src/utils/storage.js
@@ -8,7 +8,7 @@ async function read(key, isArray = false) {
if (isArray) {
data = await getArray(key);
} else {
- data = await FastStorage.getMap(key);
+ data = await MMKV.getMap(key);
}
return isArray ? data.slice() : data;
@@ -18,7 +18,7 @@ async function write(key, data) {
if (data.length !== undefined) {
return await setArray(key, data.slice());
} else {
- return await FastStorage.setMap(key, data);
+ return await MMKV.setMap(key, data);
}
}
@@ -26,17 +26,17 @@ async function readMulti(keys) {
if (keys.length <= 0) {
return [];
} else {
- let data = await FastStorage.getMultipleItems(keys.slice());
+ let data = await MMKV.getMultipleItems(keys.slice());
return !data ? undefined : data;
}
}
function remove(key) {
- FastStorage.removeItem(key);
+ MMKV.removeItem(key);
}
function clear() {
- FastStorage.clearStore();
+ MMKV.clearStore();
}
function encrypt(password, data) {
diff --git a/apps/mobile/src/views/AppearanceSettings/index.js b/apps/mobile/src/views/AppearanceSettings/index.js
index d5a806cda..a2c6bd1a1 100644
--- a/apps/mobile/src/views/AppearanceSettings/index.js
+++ b/apps/mobile/src/views/AppearanceSettings/index.js
@@ -6,7 +6,7 @@ import {
TouchableOpacity,
View,
} from 'react-native';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {
ACCENT,
@@ -99,7 +99,7 @@ const AppearanceSettings = ({navigation}) => {
onPress={() => {
changeAccentColor(item);
- FastStorage.setString('accentColor', item);
+ MMKV.setString('accentColor', item);
}}
style={{
flexDirection: 'row',
@@ -127,10 +127,10 @@ const AppearanceSettings = ({navigation}) => {
<TouchableOpacity
onPress={() => {
if (!colors.night) {
- FastStorage.setString('theme', JSON.stringify({night: true}));
+ MMKV.setString('theme', JSON.stringify({night: true}));
changeColorScheme(COLOR_SCHEME_DARK);
} else {
- FastStorage.setString('theme', JSON.stringify({night: false}));
+ MMKV.setString('theme', JSON.stringify({night: false}));
changeColorScheme(COLOR_SCHEME_LIGHT);
}
@@ -165,10 +165,10 @@ const AppearanceSettings = ({navigation}) => {
<TouchableOpacity
onPress={() => {
if (!colors.night) {
- FastStorage.setString('theme', JSON.stringify({night: true}));
+ MMKV.setString('theme', JSON.stringify({night: true}));
changeColorScheme(COLOR_SCHEME_DARK);
} else {
- FastStorage.setString('theme', JSON.stringify({night: false}));
+ MMKV.setString('theme', JSON.stringify({night: false}));
changeColorScheme(COLOR_SCHEME_LIGHT);
}
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index ba9820b48..86361f54e 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -23,7 +23,7 @@ import Container from '../../components/Container';
import {useTracked} from '../../provider';
import {w, hexToRGBA, getElevation} from '../../utils/utils';
import {ACTIONS} from '../../provider/actions';
-import FastStorage from 'react-native-fast-storage';
+import MMKV from 'react-native-mmkv-storage';
import {DDS} from '../../../App';
import {updateEvent} from '../../components/DialogManager';
import {eSendEvent} from '../../services/eventManager';
@@ -33,7 +33,7 @@ import NavigationService from '../../services/NavigationService';
export async function setSetting(settings, name, value) {
let s = {...settings};
s[name] = value;
- await FastStorage.setString('settings', JSON.stringify(s));
+ await MMKV.setString('settings', JSON.stringify(s));
updateEvent({type: ACTIONS.SETTINGS, settings: s});
}
@@ -319,7 +319,7 @@ export const Settings = ({navigation}) => {
onPress={() => {
changeAccentColor(item);
- FastStorage.setString('accentColor', item);
+ MMKV.setString('accentColor', item);
}}
style={{
flexDirection: 'row',
@@ -347,10 +347,10 @@ export const Settings = ({navigation}) => {
<TouchableOpacity
onPress={() => {
if (!colors.night) {
- FastStorage.setString('theme', JSON.stringify({night: true}));
+ MMKV.setString('theme', JSON.stringify({night: true}));
changeColorScheme(COLOR_SCHEME_DARK);
} else {
- FastStorage.setString('theme', JSON.stringify({night: false}));
+ MMKV.setString('theme', JSON.stringify({night: false}));
changeColorScheme(COLOR_SCHEME_LIGHT);
}