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
Fix: List updating incorrectly on new note creation
ammarahm-ed345338f09155
diff --git a/apps/mobile/src/components/SimpleList/NoteItemWrapper.js b/apps/mobile/src/components/SimpleList/NoteItemWrapper.jsindex 65bb6827f..4d8cb9c15 100644--- a/apps/mobile/src/components/SimpleList/NoteItemWrapper.js+++ b/apps/mobile/src/components/SimpleList/NoteItemWrapper.js@@ -23,6 +23,11 @@ export const NoteItemWrapper = ({const {colors, selectionMode} = state;const [note, setNote] = useState(item);const [editing, setEditing] = useState(false);++ useEffect(() => {+ setNote(item);+ },[item])+const onNoteChange = (data) => {if (data.id !== note.id) {return;@@ -34,7 +39,6 @@ export const NoteItemWrapper = ({if (data.closed) {setEditing(false);}-setNote(db.notes.note(data.id).data)}@@ -43,9 +47,7 @@ export const NoteItemWrapper = ({return () => {eUnSubscribeEvent(eOnNoteEdited + note.id, onNoteChange);}- }, [editing]);--+ }, [editing,item]);const style = useMemo(() => {return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};@@ -62,7 +64,6 @@ export const NoteItemWrapper = ({const onPress = async () => {if (item.conflicted) {eSendEvent(eShowMergeDialog, item);-return;}if (selectionMode) {diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.jsindex 24c87d1f1..638e8b0a9 100644--- a/apps/mobile/src/components/SimpleList/index.js+++ b/apps/mobile/src/components/SimpleList/index.js@@ -63,10 +63,15 @@ const SimpleList = ({} */setDataProvider(new DataProvider((r1, r2) => {- return r1 !== r2;++ return r1.id !== r2.id ||+ r1.locked !== r2.locked ||+ r1.pinned !== r2.pinned ||+ r1.favorite !== r2.favorite ||+ r1.title !== r2.title}).cloneWithRows(d),);- }, [listData]);+ }, [listData, searchResults]);const RenderSectionHeader = ({item}) => (<Text@@ -117,8 +122,9 @@ const SimpleList = ({if (refreshCallback) {refreshCallback();}- dispatch({type: Actions.ALL});}+ dispatch({type: Actions.ALL});+}, []);const _ListEmptyComponent = (@@ -212,6 +218,7 @@ const SimpleList = ({dataProvider={dataProvider}rowRenderer={_renderRow}onScroll={_onScroll}+ renderFooter={() => <View style={{height:400}} />}scrollViewProps={{refreshControl: (<RefreshControl@@ -336,7 +343,7 @@ const LoginCard = ({type, data}) => {};const ListHeaderComponent = ({type, data}) => {- const [state, ] = useTracked();+ const [state,] = useTracked();const searchResults = {...state.searchResults};return searchResults.type === type && searchResults.results.length > 0 ? (diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.jsindex c0c18638d..eb4ba21b2 100644--- a/apps/mobile/src/views/Editor/Functions.js+++ b/apps/mobile/src/views/Editor/Functions.js@@ -95,7 +95,6 @@ export async function loadNote(item) {const onChange = (data) => {if (!data || data === '') return;let rawData = JSON.parse(data);- console.log(content, "onChange", noteEdited);if (rawData.type === 'content') {if (!id && rawData.text !== "" ||@@ -231,9 +230,7 @@ async function addToCollection(id) {export async function saveNote() {if (!checkIfContentIsSavable()) return;- console.log("saving", id);let lockedNote = id ? db.notes.note(id).data.locked : null;- post('saving', 'Saving');if (!lockedNote) {let rId = await db.notes.add({@@ -244,9 +241,8 @@ export async function saveNote() {},id: id,});- console.log(rId);await setNoteInEditorAfterSaving(id, rId);- if (saveCounter < 2) {+ if (saveCounter < 3) {updateEvent({type: Actions.NOTES,});@@ -255,6 +251,9 @@ export async function saveNote() {eSendEvent(eOnNoteEdited + rId, {id: rId});+++if (id) {await addToCollection(id);updateEvent({