Skip to content

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

undo some changes

ammarahm-ed80e6b977b6b1
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index 4d371ce3c..30b68f987 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -1,15 +1,15 @@
-import React, { useEffect, useState } from 'react';
+import React, {useEffect, useState} from 'react';
import MMKV from 'react-native-mmkv-storage';
import Orientation from 'react-native-orientation';
-import { Loading } from './Loading';
-import { getColorScheme, scale, updateSize } from './src/common/common';
-import { useTracked } from './src/provider';
-import { ACTIONS } from './src/provider/actions';
-import { defaultState } from './src/provider/defaultState';
-import { eSubscribeEvent, eUnSubscribeEvent } from './src/services/eventManager';
-import { eDispatchAction } from './src/services/events';
-import { db, DDS } from './src/utils/utils';
-import { SafeAreaContext, SafeAreaProvider } from 'react-native-safe-area-context';
+import {Loading} from './Loading';
+import {getColorScheme, scale, updateSize} from './src/common/common';
+import {useTracked} from './src/provider';
+import {ACTIONS} from './src/provider/actions';
+import {defaultState} from './src/provider/defaultState';
+import {eSubscribeEvent, eUnSubscribeEvent} from './src/services/eventManager';
+import {eDispatchAction} from './src/services/events';
+import {db, DDS} from './src/utils/utils';
+import {SafeAreaProvider} from 'react-native-safe-area-context';
const App = () => {
const [state, dispatch] = useTracked();
@@ -44,9 +44,8 @@ const App = () => {
useEffect(() => {
Initialize().then(() => {
db.init().then(async () => {
-
let user = await db.user.get();
- dispatch({ type: ACTIONS.USER, user: user });
+ dispatch({type: ACTIONS.USER, user: user});
setInit(true);
});
@@ -59,7 +58,7 @@ const App = () => {
let s;
try {
s = await MMKV.getStringAsync('settings');
- } catch (e) { }
+ } catch (e) {}
if (typeof s !== 'string') {
s = defaultState.settings;
s = JSON.stringify(s);
@@ -67,7 +66,7 @@ const App = () => {
await MMKV.setStringAsync('settings', s);
- dispatch({ type: ACTIONS.SETTINGS, s });
+ dispatch({type: ACTIONS.SETTINGS, s});
} else {
s = JSON.parse(s);
if (s.fontScale) {
@@ -77,24 +76,21 @@ const App = () => {
}
updateSize();
- dispatch({ type: ACTIONS.SETTINGS, settings: { ...s } });
+ dispatch({type: ACTIONS.SETTINGS, settings: {...s}});
}
- dispatch({ type: ACTIONS.THEME, colors: newColors });
+ dispatch({type: ACTIONS.THEME, colors: newColors});
}
if (!init) {
return <></>;
}
return (
-
-
<SafeAreaProvider>
<>
<I.Initialize />
<Loading />
</>
</SafeAreaProvider>
-
);
};
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index d9a430c89..21d94259f 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -1,13 +1,13 @@
import React from 'react';
-import { Dimensions, Text, TouchableOpacity, View } from 'react-native';
+import {Dimensions, Text, TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { ph, pv, SIZE, WEIGHT } from '../../common/common';
-import { eSendEvent, openVault } from '../../services/eventManager';
-import { eOnLoadNote, eShowMergeDialog } from '../../services/events';
-import { openEditorAnimation } from '../../utils/animations';
-import { DDS, timeSince } from '../../utils/utils';
-import { ActionSheetEvent, simpleDialogEvent } from '../DialogManager/recievers';
-import { TEMPLATE_TRASH } from '../DialogManager/templates';
+import {ph, pv, SIZE, WEIGHT} from '../../common/common';
+import {eSendEvent, openVault} from '../../services/eventManager';
+import {eOnLoadNote, eShowMergeDialog} from '../../services/events';
+import {openEditorAnimation} from '../../utils/animations';
+import {DDS, timeSince} from '../../utils/utils';
+import {ActionSheetEvent, simpleDialogEvent} from '../DialogManager/recievers';
+import {TEMPLATE_TRASH} from '../DialogManager/templates';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -64,9 +64,6 @@ export default class NoteItem extends React.Component {
pinned,
index,
} = this.props;
-
-
- console.log('rerendering again', item);
return (
<View
style={[
@@ -172,14 +169,15 @@ export default class NoteItem extends React.Component {
borderRadius: 100,
backgroundColor: item,
marginRight: -4.5,
- }}></View>
+ }}
+ />
))}
</View>
) : null}
{item.locked ? (
<Icon
- style={{ marginRight: 10 }}
+ style={{marginRight: 10}}
name="lock"
size={SIZE.xs}
color={colors.icon}
@@ -188,7 +186,7 @@ export default class NoteItem extends React.Component {
{item.favorite ? (
<Icon
- style={{ marginRight: 10 }}
+ style={{marginRight: 10}}
name="star"
size={SIZE.xs + 1}
color="orange"
@@ -216,9 +214,9 @@ export default class NoteItem extends React.Component {
textAlignVertical: 'center',
fontFamily: WEIGHT.regular,
}}>
- {'Deleted on: ' +
- new Date(item.dateDeleted).toISOString().slice(0, 10) +
- ' '}
+ {'Deleted on: ' + item && item.dateDeleted
+ ? new Date(item.dateDeleted).toISOString().slice(0, 10)
+ : null + ' '}
</Text>
<Text
style={{
@@ -232,30 +230,24 @@ export default class NoteItem extends React.Component {
</>
) : null}
- {
- item.conflicted ? <View
+ {item.conflicted ? (
+ <View
style={{
backgroundColor: colors.errorText,
borderRadius: 2.5,
paddingHorizontal: 4,
position: 'absolute',
- right: 20
- }}
- >
+ right: 20,
+ }}>
<Text
- style={
- {
- fontSize: SIZE.xs - 1,
- color: 'white',
- }
- }
- >
+ style={{
+ fontSize: SIZE.xs - 1,
+ color: 'white',
+ }}>
CONFLICTS
- </Text>
- </View> : null
- }
-
-
+ </Text>
+ </View>
+ ) : null}
</View>
</View>
</>
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 7938fd8ae..b7833828d 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -163,9 +163,9 @@ export const NotebookItem = ({
textAlignVertical: 'center',
fontFamily: WEIGHT.regular,
}}>
- {'Deleted on: ' +
- new Date(item.dateDeleted).toISOString().slice(0, 10) +
- ' '}
+ {'Deleted on: ' + item && item.dateDeleted
+ ? new Date(item.dateDeleted).toISOString().slice(0, 10)
+ : null + ' '}
</Text>
<Text
style={{
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index e96c3a987..2b0ab16e3 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -1,14 +1,14 @@
import React from 'react';
-import { FlatList, Platform, RefreshControl, Text, View } from 'react-native';
-import { SIZE, WEIGHT } from '../../common/common';
-import { useTracked } from '../../provider';
-import { ACTIONS } from '../../provider/actions';
-import { eSendEvent } from '../../services/eventManager';
-import { eClearSearch, eScrollEvent } from '../../services/events';
-import { hexToRGBA } from '../../utils/utils';
-import { NotebookItem } from '../NotebookItem';
+import {FlatList, Platform, RefreshControl, Text, View} from 'react-native';
+import {SIZE, WEIGHT} from '../../common/common';
+import {useTracked} from '../../provider';
+import {ACTIONS} from '../../provider/actions';
+import {eSendEvent} from '../../services/eventManager';
+import {eClearSearch, eScrollEvent} from '../../services/events';
+import {hexToRGBA} from '../../utils/utils';
+import {NotebookItem} from '../NotebookItem';
import SelectionWrapper from '../SelectionWrapper';
-import { useSafeArea } from 'react-native-safe-area-context';
+import {useSafeArea} from 'react-native-safe-area-context';
const SimpleList = ({
data,
@@ -25,8 +25,8 @@ const SimpleList = ({
noteToMove,
}) => {
const [state, dispatch] = useTracked();
- const { colors, selectionMode } = state;
- const searchResults = { ...state.searchResults };
+ const {colors, selectionMode} = state;
+ const searchResults = {...state.searchResults};
const insets = useSafeArea();
const _onScroll = event => {
if (!event) return;
@@ -63,8 +63,8 @@ const SimpleList = ({
? 135
: 135 - 60
: data[0] && !selectionMode
- ? 155 - insets.top
- : (155 - insets.top) - 60,
+ ? 155 - insets.top
+ : 155 - insets.top - 60,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
@@ -91,70 +91,70 @@ const SimpleList = ({
</Text>
</View>
) : (
- <View
- style={{
- marginTop:
- Platform.OS == 'ios'
- ? data[0] && !selectionMode
- ? 135
- : 135 - 60
- : data[0] && !selectionMode
- ? 155
- : 155 - 60,
- }}>
- {pinned && pinned.notebooks && pinned.notebooks.length > 0 ? (
- <>
- <FlatList
- data={pinned.notebooks}
- keyExtractor={(item, index) => item.id.toString()}
- renderItem={({ item, index }) =>
- item.type === 'notebook' ? (
- <SelectionWrapper
- index={index}
- currentEditingNote={false}
+ <View
+ style={{
+ marginTop:
+ Platform.OS == 'ios'
+ ? data[0] && !selectionMode
+ ? 135
+ : 135 - 60
+ : data[0] && !selectionMode
+ ? 155
+ : 155 - 60,
+ }}>
+ {pinned && pinned.notebooks && pinned.notebooks.length > 0 ? (
+ <>
+ <FlatList
+ data={pinned.notebooks}
+ keyExtractor={(item, index) => item.id.toString()}
+ renderItem={({item, index}) =>
+ item.type === 'notebook' ? (
+ <SelectionWrapper
+ index={index}
+ currentEditingNote={false}
+ pinned={true}
+ background={
+ Platform.ios
+ ? hexToRGBA(colors.accent + '19')
+ : hexToRGBA(colors.shade)
+ }
+ item={item}>
+ <NotebookItem
+ hideMore={hideMore}
+ customStyle={{
+ width: '100%',
+ paddingTop: 15,
+ paddingRight: 18,
+ marginBottom: 10,
+ marginTop: 15,
+ borderBottomWidth: 0,
+ marginHorizontal: 0,
+ }}
+ isMove={isMove}
+ selectionMode={selectionMode}
+ onLongPress={() => {
+ if (!selectionMode) {
+ dispatch({
+ type: ACTIONS.SELECTION_MODE,
+ enabled: true,
+ });
+ }
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ noteToMove={noteToMove}
+ item={item}
pinned={true}
- background={
- Platform.ios
- ? hexToRGBA(colors.accent + '19')
- : hexToRGBA(colors.shade)
- }
- item={item}>
- <NotebookItem
- hideMore={hideMore}
- customStyle={{
- width: '100%',
- paddingTop: 15,
- paddingRight: 18,
- marginBottom: 10,
- marginTop: 15,
- borderBottomWidth: 0,
- marginHorizontal: 0,
- }}
- isMove={isMove}
- selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: true,
- });
- }
- dispatch({ type: ACTIONS.SELECTED_ITEMS, item: item });
- }}
- noteToMove={noteToMove}
- item={item}
- pinned={true}
- index={index}
- colors={colors}
- />
- </SelectionWrapper>
- ) : null
- }
- />
- </>
- ) : null}
- </View>
- );
+ index={index}
+ colors={colors}
+ />
+ </SelectionWrapper>
+ ) : null
+ }
+ />
+ </>
+ ) : null}
+ </View>
+ );
const _ListEmptyComponent = (
<View
@@ -188,8 +188,8 @@ const SimpleList = ({
<FlatList
data={
searchResults.type === type &&
- focused &&
- searchResults.results.length > 0
+ focused &&
+ searchResults.results.length > 0
? searchResults.results
: data
}
diff --git a/apps/mobile/src/services/Navigator.js b/apps/mobile/src/services/Navigator.js
index 7181cf2d0..dfa31c17c 100644
--- a/apps/mobile/src/services/Navigator.js
+++ b/apps/mobile/src/services/Navigator.js
@@ -14,10 +14,10 @@ import Settings from '../views/Settings';
import Signup from '../views/Signup';
import Tags from '../views/Tags';
import Trash from '../views/Trash';
-import { createStackNavigator } from 'react-navigation-stack';
+import {createStackNavigator} from 'react-navigation-stack';
const fade = props => {
- const { position, scene } = props;
+ const {position, scene} = props;
const index = scene.index;
@@ -31,11 +31,10 @@ const fade = props => {
return {
opacity,
- transform: [{ translateX }, { translateY }],
+ transform: [{translateX}, {translateY}],
};
};
-
export const TopLevelNavigator = createStackNavigator(
{
Home: {
@@ -89,21 +88,19 @@ export const TopLevelNavigator = createStackNavigator(
Notebook: {
screen: Notebook,
},
-
},
{
initialRouteName: 'Home',
-
defaultNavigationOptions: {
- gesturesEnabled: false,
+ cardOverlayEnabled: true,
+ cardShadowEnabled: true,
+ animationEnabled: false,
+ gestureEnabled: false,
headerStyle: {
backgroundColor: 'transparent',
borderBottomWidth: 0,
height: 0,
},
},
- cardOverlayEnabled: true,
- cardShadowEnabled: true,
- animationEnabled: false,
},
-);
\ No newline at end of file
+);