A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
update FastStorage API
ammarahm-ed0de0f50167cf
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex a25b4f584..9a3c5972c 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -167,12 +167,12 @@ const App = () => {async function updateAppTheme(colors = colors) {let newColors = await getColorScheme(colors);- let s = await FastStorage.getItem('settings');+ let s = await FastStorage.getString('settings');if (typeof s !== 'string') {s = defaultState.settings;s = JSON.stringify(s);- await FastStorage.setItem('settings', s);+ await FastStorage.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.jsindex 462abf182..bbbdaefdf 100755--- a/apps/mobile/src/common/common.js+++ b/apps/mobile/src/common/common.js@@ -187,18 +187,18 @@ export function setColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {}export async function getColorScheme() {- let accentColor = await FastStorage.getItem('accentColor');- let t = await FastStorage.getItem('theme');+ let accentColor = await FastStorage.getString('accentColor');+ let t = await FastStorage.getString('theme');if (typeof accentColor !== 'string') {- FastStorage.setItem('accentColor', '#0560FF');+ FastStorage.setString('accentColor', '#0560FF');setAccentColor('#0560FF');} else {setAccentColor(accentColor);}if (typeof t !== 'string') {- FastStorage.setItem('theme', JSON.stringify({night: false}));+ FastStorage.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.jsindex 0edbf6cd4..09ec49af1 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -283,10 +283,10 @@ export const ActionSheetComponent = ({icon: 'theme-light-dark',func: () => {if (!colors.night) {- FastStorage.setItem('theme', JSON.stringify({night: true}));+ FastStorage.setString('theme', JSON.stringify({night: true}));changeColorScheme(COLOR_SCHEME_DARK);} else {- FastStorage.setItem('theme', JSON.stringify({night: false}));+ FastStorage.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.jsindex 1cb18be56..d9a350ba1 100644--- a/apps/mobile/src/components/EditorMenu/index.js+++ b/apps/mobile/src/components/EditorMenu/index.js@@ -326,13 +326,13 @@ export const EditorMenu = ({updateProps = () => {}, timestamp}) => {icon: 'moon',func: () => {if (!colors.night) {- FastStorage.setItem(+ FastStorage.setString('theme',JSON.stringify(COLOR_SCHEME_DARK),);changeColorScheme(COLOR_SCHEME_DARK);} else {- FastStorage.setItem(+ FastStorage.setString('theme',JSON.stringify(COLOR_SCHEME_LIGHT),);diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.jsindex 2730e8cc3..b131edb9e 100644--- a/apps/mobile/src/components/Menu/index.js+++ b/apps/mobile/src/components/Menu/index.js@@ -96,10 +96,10 @@ export const Menu = ({icon: 'theme-light-dark',func: () => {if (!colors.night) {- FastStorage.setItem('theme', JSON.stringify({night: true}));+ FastStorage.setString('theme', JSON.stringify({night: true}));changeColorScheme(COLOR_SCHEME_DARK);} else {- FastStorage.setItem('theme', JSON.stringify({night: false}));+ FastStorage.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.jsindex fcb3c4a29..d4721b89c 100644--- a/apps/mobile/src/utils/storage.js+++ b/apps/mobile/src/utils/storage.js@@ -1,18 +1,33 @@import {NativeModules} from 'react-native';-import FastStorage from 'react-native-fast-storage';+import FastStorage, {getArray, setArray} from 'react-native-fast-storage';var Aes = NativeModules.Aes;-async function read(key) {- let json = await FastStorage.getItem(key);-- return !json ? undefined : JSON.parse(json);+async function read(key, isArray) {+ let data;+ if (isArray) {+ data = await getArray(key);+ } else {+ data = await FastStorage.getMap(key);+ }+ return !data ? undefined : data;}async function write(key, data) {- let json = JSON.stringify(data);+ if (Array.isArray(data)) {+ return await setArray(key, data);+ } else {+ return await FastStorage.setMap(key, data);+ }+}- return await FastStorage.setItem(key, json);+async function readMulti(keys) {+ if (keys.length <= 0) {+ return [];+ } else {+ let data = await FastStorage.getMultipleItems(keys);+ return !data ? undefined : data;+ }}function remove(key) {@@ -48,4 +63,4 @@ function decrypt(password, data) {});}-export default {read, write, remove, clear, encrypt, decrypt};+export default {read, write, readMulti, remove, clear, encrypt, decrypt};diff --git a/apps/mobile/src/views/AppearanceSettings/index.js b/apps/mobile/src/views/AppearanceSettings/index.jsindex a332e75db..d5a806cda 100644--- a/apps/mobile/src/views/AppearanceSettings/index.js+++ b/apps/mobile/src/views/AppearanceSettings/index.js@@ -99,7 +99,7 @@ const AppearanceSettings = ({navigation}) => {onPress={() => {changeAccentColor(item);- FastStorage.setItem('accentColor', item);+ FastStorage.setString('accentColor', item);}}style={{flexDirection: 'row',@@ -127,10 +127,10 @@ const AppearanceSettings = ({navigation}) => {<TouchableOpacityonPress={() => {if (!colors.night) {- FastStorage.setItem('theme', JSON.stringify({night: true}));+ FastStorage.setString('theme', JSON.stringify({night: true}));changeColorScheme(COLOR_SCHEME_DARK);} else {- FastStorage.setItem('theme', JSON.stringify({night: false}));+ FastStorage.setString('theme', JSON.stringify({night: false}));changeColorScheme(COLOR_SCHEME_LIGHT);}@@ -165,10 +165,10 @@ const AppearanceSettings = ({navigation}) => {<TouchableOpacityonPress={() => {if (!colors.night) {- FastStorage.setItem('theme', JSON.stringify({night: true}));+ FastStorage.setString('theme', JSON.stringify({night: true}));changeColorScheme(COLOR_SCHEME_DARK);} else {- FastStorage.setItem('theme', JSON.stringify({night: false}));+ FastStorage.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.jsindex d38540478..ba9820b48 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -33,7 +33,7 @@ import NavigationService from '../../services/NavigationService';export async function setSetting(settings, name, value) {let s = {...settings};s[name] = value;- await FastStorage.setItem('settings', JSON.stringify(s));+ await FastStorage.setString('settings', JSON.stringify(s));updateEvent({type: ACTIONS.SETTINGS, settings: s});}@@ -319,7 +319,7 @@ export const Settings = ({navigation}) => {onPress={() => {changeAccentColor(item);- FastStorage.setItem('accentColor', item);+ FastStorage.setString('accentColor', item);}}style={{flexDirection: 'row',@@ -347,10 +347,10 @@ export const Settings = ({navigation}) => {<TouchableOpacityonPress={() => {if (!colors.night) {- FastStorage.setItem('theme', JSON.stringify({night: true}));+ FastStorage.setString('theme', JSON.stringify({night: true}));changeColorScheme(COLOR_SCHEME_DARK);} else {- FastStorage.setItem('theme', JSON.stringify({night: false}));+ FastStorage.setString('theme', JSON.stringify({night: false}));changeColorScheme(COLOR_SCHEME_LIGHT);}