mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
minor changes
This commit is contained in:
@@ -29,12 +29,10 @@ const App = () => {
|
|||||||
: require('./index.mobile');
|
: require('./index.mobile');
|
||||||
|
|
||||||
const _onOrientationChange = (o) => {
|
const _onOrientationChange = (o) => {
|
||||||
console.log(o, 'orientation');
|
|
||||||
let smallTab = DDS.isSmallTab;
|
let smallTab = DDS.isSmallTab;
|
||||||
DDS.setNewValues();
|
DDS.setNewValues();
|
||||||
DDS.checkSmallTab(o);
|
DDS.checkSmallTab(o);
|
||||||
if (smallTab === DDS.isSmallTab) {
|
if (smallTab === DDS.isSmallTab) {
|
||||||
console.log('nothing changed');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,14 +90,11 @@ const App = () => {
|
|||||||
dispatch({type: Actions.ALL});
|
dispatch({type: Actions.ALL});
|
||||||
}, resetApp = () => {
|
}, resetApp = () => {
|
||||||
note = getNote();
|
note = getNote();
|
||||||
console.log(note, 'NOTE BEFORE RELOAD');
|
|
||||||
setInit(false);
|
setInit(false);
|
||||||
Initialize().then(async () => {
|
Initialize().then(async () => {
|
||||||
setInit(true);
|
setInit(true);
|
||||||
await sleep(300);
|
await sleep(300);
|
||||||
console.log(note, 'NOTE ON RELOAD');
|
|
||||||
if (note && note.id) {
|
if (note && note.id) {
|
||||||
console.log(note);
|
|
||||||
eSendEvent(eOnLoadNote, note);
|
eSendEvent(eOnLoadNote, note);
|
||||||
if (DDS.isPhone || DDS.isSmallTab) {
|
if (DDS.isPhone || DDS.isSmallTab) {
|
||||||
openEditorAnimation();
|
openEditorAnimation();
|
||||||
@@ -147,7 +142,6 @@ const App = () => {
|
|||||||
user = await db.user.get();
|
user = await db.user.get();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
console.log(e, "ERROR IN DB")
|
|
||||||
} finally {
|
} finally {
|
||||||
if (user) {
|
if (user) {
|
||||||
dispatch({type: Actions.USER, user: user});
|
dispatch({type: Actions.USER, user: user});
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as Animatable from 'react-native-animatable';
|
import * as Animatable from 'react-native-animatable';
|
||||||
import {DialogManager} from './src/components/DialogManager';
|
|
||||||
import {Toast} from './src/components/Toast';
|
|
||||||
import {useTracked} from './src/provider';
|
import {useTracked} from './src/provider';
|
||||||
import {dWidth} from './src/utils';
|
import {dWidth} from './src/utils';
|
||||||
import {SIZE, WEIGHT} from "./src/utils/SizeUtils";
|
import {SIZE, WEIGHT} from "./src/utils/SizeUtils";
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import Share from 'react-native-share';
|
|||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
import {useTracked} from '../../provider';
|
import {useTracked} from '../../provider';
|
||||||
import {Actions} from '../../provider/Actions';
|
import {Actions} from '../../provider/Actions';
|
||||||
import {eSendEvent, openVault, ToastEvent} from '../../services/EventManager';
|
import {eSendEvent, openVault, sendNoteEditedEvent, ToastEvent} from '../../services/EventManager';
|
||||||
import {
|
import {
|
||||||
eOnNoteEdited,
|
eOnNoteEdited,
|
||||||
eOpenLoginDialog,
|
eOpenLoginDialog,
|
||||||
@@ -37,6 +37,7 @@ import {opacity, ph, pv, SIZE, WEIGHT} from "../../utils/SizeUtils";
|
|||||||
import {db} from "../../utils/DB";
|
import {db} from "../../utils/DB";
|
||||||
import {DDS} from "../../services/DeviceDetection";
|
import {DDS} from "../../services/DeviceDetection";
|
||||||
import {MMKV} from "../../utils/MMKV";
|
import {MMKV} from "../../utils/MMKV";
|
||||||
|
import id from "notes-core/utils/id";
|
||||||
|
|
||||||
const w = Dimensions.get('window').width;
|
const w = Dimensions.get('window').width;
|
||||||
const h = Dimensions.get('window').height;
|
const h = Dimensions.get('window').height;
|
||||||
@@ -115,7 +116,6 @@ export const ActionSheetComponent = ({
|
|||||||
if (event.nativeEvent.key === 'Backspace') {
|
if (event.nativeEvent.key === 'Backspace') {
|
||||||
if (backPressCount === 0 && !tagToAdd) {
|
if (backPressCount === 0 && !tagToAdd) {
|
||||||
backPressCount = 1;
|
backPressCount = 1;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (backPressCount === 1 && !tagToAdd) {
|
if (backPressCount === 1 && !tagToAdd) {
|
||||||
@@ -136,17 +136,15 @@ export const ActionSheetComponent = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (event.nativeEvent.key === ' ') {
|
} else if (event.nativeEvent.key === ' ') {
|
||||||
_onSubmit();
|
await _onSubmit();
|
||||||
tagsInputRef.current?.setNativeProps({
|
tagsInputRef.current?.setNativeProps({
|
||||||
text: '',
|
text: '',
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
} else if (event.nativeEvent.key === ',') {
|
} else if (event.nativeEvent.key === ',') {
|
||||||
_onSubmit();
|
await _onSubmit();
|
||||||
tagsInputRef.current?.setNativeProps({
|
tagsInputRef.current?.setNativeProps({
|
||||||
text: '',
|
text: '',
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -341,7 +339,7 @@ export const ActionSheetComponent = ({
|
|||||||
await db.notebooks.notebook(note.id).favorite();
|
await db.notebooks.notebook(note.id).favorite();
|
||||||
}
|
}
|
||||||
dispatch({type: Actions.FAVORITES});
|
dispatch({type: Actions.FAVORITES});
|
||||||
eSendEvent(eOnNoteEdited , {id: note.id, noEdit: true});
|
sendNoteEditedEvent(note.id, false,true)
|
||||||
localRefresh(item.type,true);
|
localRefresh(item.type,true);
|
||||||
},
|
},
|
||||||
close: false,
|
close: false,
|
||||||
@@ -365,7 +363,7 @@ export const ActionSheetComponent = ({
|
|||||||
db.vault
|
db.vault
|
||||||
.add(note.id)
|
.add(note.id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
eSendEvent(eOnNoteEdited , {id: note.id, noEdit: true});
|
sendNoteEditedEvent(note.id, false,true)
|
||||||
close();
|
close();
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
@@ -398,10 +396,10 @@ export const ActionSheetComponent = ({
|
|||||||
await db.notes
|
await db.notes
|
||||||
.note(note.id)
|
.note(note.id)
|
||||||
.untag(oldProps.tags[oldProps.tags.indexOf(tag)]);
|
.untag(oldProps.tags[oldProps.tags.indexOf(tag)]);
|
||||||
eSendEvent(eOnNoteEdited , {id: note.id, noEdit: true});
|
sendNoteEditedEvent(note.id, false,true)
|
||||||
dispatch({type: Actions.TAGS});
|
dispatch({type: Actions.TAGS});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
eSendEvent(eOnNoteEdited , {id: note.id, noEdit: true});
|
sendNoteEditedEvent(note.id, false,true)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
@@ -454,7 +452,7 @@ export const ActionSheetComponent = ({
|
|||||||
await db.notes.note(note.id).color(color.name);
|
await db.notes.note(note.id).color(color.name);
|
||||||
}
|
}
|
||||||
dispatch({type: Actions.COLORS});
|
dispatch({type: Actions.COLORS});
|
||||||
eSendEvent(eOnNoteEdited , {id: note.id, noEdit: true});
|
sendNoteEditedEvent(note.id, false,true)
|
||||||
localRefresh(note.type,true);
|
localRefresh(note.type,true);
|
||||||
}}
|
}}
|
||||||
customStyle={{
|
customStyle={{
|
||||||
|
|||||||
@@ -107,11 +107,11 @@ const RestoreDialog = () => {
|
|||||||
|
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
flexDirection: 'row',
|
justifyContent: 'space-between',
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: 50,
|
height: 50,
|
||||||
marginTop: DDS.isTab ? 0 : insets.top,
|
marginTop: DDS.isTab ? 0 : insets.top,
|
||||||
|
flexDirection:"row",
|
||||||
}}>
|
}}>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
name="close"
|
name="close"
|
||||||
@@ -120,7 +120,6 @@ const RestoreDialog = () => {
|
|||||||
customStyle={{
|
customStyle={{
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
position: 'absolute',
|
|
||||||
textAlignVertical: 'center',
|
textAlignVertical: 'center',
|
||||||
left: 0,
|
left: 0,
|
||||||
}}
|
}}
|
||||||
@@ -134,16 +133,13 @@ const RestoreDialog = () => {
|
|||||||
}}>
|
}}>
|
||||||
Choose a Backup
|
Choose a Backup
|
||||||
</Text>
|
</Text>
|
||||||
|
<View style={ {
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
}}/>
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: colors.icon,
|
|
||||||
fontFamily: WEIGHT.regular,
|
|
||||||
fontSize: SIZE.xs + 1,
|
|
||||||
textAlign: 'center',
|
|
||||||
}}>
|
|
||||||
Phone Storage/Notesnook/backups/
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<FlatList
|
<FlatList
|
||||||
data={files}
|
data={files}
|
||||||
|
|||||||
@@ -29,20 +29,21 @@ export const NoteItemWrapper = ({
|
|||||||
},[item])
|
},[item])
|
||||||
|
|
||||||
const onNoteChange = (data) => {
|
const onNoteChange = (data) => {
|
||||||
if (data.id !== note.id) {
|
if (data.id !== note.id || data.closed) {
|
||||||
if (editing) {
|
if (editing) {
|
||||||
setEditing(false);
|
setEditing(false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (editing !== true && !data.noEdit) {
|
if (!editing && !data.noEdit) {
|
||||||
setEditing(true);
|
setEditing(true);
|
||||||
}
|
}
|
||||||
|
let newNote = db.notes.note(data.id).data;
|
||||||
|
|
||||||
if (data.closed) {
|
if (!data.noEdit && newNote.title === note.title && newNote.headline === note.headline) {
|
||||||
setEditing(false);
|
return;
|
||||||
}
|
}
|
||||||
setNote(db.notes.note(data.id).data);
|
setNote(newNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {DeviceEventEmitter} from 'react-native';
|
import {DeviceEventEmitter} from 'react-native';
|
||||||
import {eHideToast, eOpenVaultDialog, eShowToast} from '../utils/Events';
|
import {eHideToast, eOnNoteEdited, eOpenVaultDialog, eShowToast} from '../utils/Events';
|
||||||
|
|
||||||
export const eSubscribeEvent = (eventName, action) => {
|
export const eSubscribeEvent = (eventName, action) => {
|
||||||
DeviceEventEmitter.addListener(eventName, action);
|
DeviceEventEmitter.addListener(eventName, action);
|
||||||
@@ -32,6 +32,12 @@ export const openVault = (
|
|||||||
deleteNote,
|
deleteNote,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function sendNoteEditedEvent(id="",closed=false,noEdit=false) {
|
||||||
|
eSendEvent(eOnNoteEdited , {id,closed, noEdit});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const ToastEvent = {
|
export const ToastEvent = {
|
||||||
show: (
|
show: (
|
||||||
message,
|
message,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {createRef} from 'react';
|
|||||||
import {Linking, Platform} from 'react-native';
|
import {Linking, Platform} from 'react-native';
|
||||||
import {updateEvent} from '../../components/DialogManager/recievers';
|
import {updateEvent} from '../../components/DialogManager/recievers';
|
||||||
import {Actions} from '../../provider/Actions';
|
import {Actions} from '../../provider/Actions';
|
||||||
import {eSendEvent} from '../../services/EventManager';
|
import {eSendEvent, sendNoteEditedEvent} from '../../services/EventManager';
|
||||||
import {eOnNoteEdited, refreshNotesPage} from '../../utils/Events';
|
import {eOnNoteEdited, refreshNotesPage} from '../../utils/Events';
|
||||||
import {editing} from '../../utils';
|
import {editing} from '../../utils';
|
||||||
import {sleep, timeConverter} from "../../utils/TimeUtils";
|
import {sleep, timeConverter} from "../../utils/TimeUtils";
|
||||||
@@ -120,7 +120,7 @@ export async function loadNote(item) {
|
|||||||
} else {
|
} else {
|
||||||
await setNote(item);
|
await setNote(item);
|
||||||
canSave = false;
|
canSave = false;
|
||||||
eSendEvent(eOnNoteEdited , {id: item.id});
|
sendNoteEditedEvent(item.id)
|
||||||
await loadNoteInEditor();
|
await loadNoteInEditor();
|
||||||
}
|
}
|
||||||
noteEdited = false;
|
noteEdited = false;
|
||||||
@@ -170,7 +170,7 @@ export async function clearEditor() {
|
|||||||
await saveNote("clearEditor");
|
await saveNote("clearEditor");
|
||||||
}
|
}
|
||||||
if (note && note.id) {
|
if (note && note.id) {
|
||||||
eSendEvent(eOnNoteEdited , {id: note.id, closed: true});
|
sendNoteEditedEvent(note.id,true)
|
||||||
}
|
}
|
||||||
saveCounter = 0;
|
saveCounter = 0;
|
||||||
post('reset');
|
post('reset');
|
||||||
@@ -261,15 +261,17 @@ export async function saveNote(caller) {
|
|||||||
},
|
},
|
||||||
id: id,
|
id: id,
|
||||||
});
|
});
|
||||||
await setNoteInEditorAfterSaving(id, rId);
|
if (!id) {
|
||||||
if (saveCounter < 3) {
|
|
||||||
updateEvent({
|
updateEvent({
|
||||||
type: Actions.NOTES,
|
type: Actions.NOTES,
|
||||||
});
|
});
|
||||||
eSendEvent(refreshNotesPage);
|
eSendEvent(refreshNotesPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
eSendEvent(eOnNoteEdited, {id: rId});
|
sendNoteEditedEvent(rId)
|
||||||
|
|
||||||
|
await setNoteInEditorAfterSaving(id, rId);
|
||||||
|
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
await addToCollection(id);
|
await addToCollection(id);
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import React, {useCallback, useEffect} from 'react';
|
import React, {useCallback, useEffect} from 'react';
|
||||||
import {Dimensions} from 'react-native';
|
|
||||||
import Orientation from 'react-native-orientation';
|
|
||||||
import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';
|
import {ContainerBottomButton} from '../../components/Container/ContainerBottomButton';
|
||||||
import {Placeholder} from '../../components/ListPlaceholders';
|
import {Placeholder} from '../../components/ListPlaceholders';
|
||||||
import SimpleList from '../../components/SimpleList';
|
import SimpleList from '../../components/SimpleList';
|
||||||
@@ -12,7 +10,7 @@ import {eOnLoadNote, eScrollEvent} from '../../utils/Events';
|
|||||||
import {openEditorAnimation} from '../../utils/Animations';
|
import {openEditorAnimation} from '../../utils/Animations';
|
||||||
import {DDS} from "../../services/DeviceDetection";
|
import {DDS} from "../../services/DeviceDetection";
|
||||||
|
|
||||||
export const Home = ({route, navigation}) => {
|
export const Home = ({navigation}) => {
|
||||||
const [state, dispatch] = useTracked();
|
const [state, dispatch] = useTracked();
|
||||||
const {notes} = state;
|
const {notes} = state;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user