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