From 35f584f4e240fe55102be9d3c1aa4ce1f95f35c3 Mon Sep 17 00:00:00 2001 From: Mo Date: Tue, 22 Mar 2022 12:46:49 -0500 Subject: [PATCH] fix: do not modify timestamps when modifying note metadata --- package.json | 6 ++-- src/lib/snjs_helper_hooks.ts | 18 ++++++---- src/screens/Notes/NoteCell.tsx | 10 +++--- .../Settings/Sections/OptionsSection.tsx | 2 +- src/screens/SideMenu/NoteSideMenu.tsx | 34 ++++++++++++------- yarn.lock | 8 ++--- 6 files changed, 46 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 7cd00186..83dd2afc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "standardnotes-mobile", - "version": "3.13.0", - "user-version": "3.13.0", + "version": "3.14.0", + "user-version": "3.14.0", "private": true, "license": "AGPL-3.0-or-later", "scripts": { @@ -36,7 +36,7 @@ "@standardnotes/react-native-textview": "1.0.2", "@standardnotes/react-native-utils": "1.0.1", "@standardnotes/sncrypto-common": "1.7.3", - "@standardnotes/snjs": "2.89.4", + "@standardnotes/snjs": "2.90.0", "@standardnotes/stylekit": "5.17.0", "@types/styled-components-react-native": "5.1.3", "js-base64": "^3.7.2", diff --git a/src/lib/snjs_helper_hooks.ts b/src/lib/snjs_helper_hooks.ts index 33e5fb00..51b0ca3d 100644 --- a/src/lib/snjs_helper_hooks.ts +++ b/src/lib/snjs_helper_hooks.ts @@ -447,18 +447,24 @@ export const useChangeNote = ( note: SNNote | undefined, editor: NoteViewController | undefined = undefined ) => { - // Context const application = React.useContext(ApplicationContext); const [canChangeNote] = useChangeNoteChecks(note, editor); const changeNote = useCallback( - async (mutate: (mutator: NoteMutator) => void) => { + async ( + mutate: (mutator: NoteMutator) => void, + updateTimestamps: boolean + ) => { if (await canChangeNote()) { - await application?.mutator.changeAndSaveItem(note!.uuid, mutator => { - const noteMutator = mutator as NoteMutator; - mutate(noteMutator); - }); + await application?.mutator.changeAndSaveItem( + note!.uuid, + mutator => { + const noteMutator = mutator as NoteMutator; + mutate(noteMutator); + }, + updateTimestamps + ); } }, [application, note, canChangeNote] diff --git a/src/screens/Notes/NoteCell.tsx b/src/screens/Notes/NoteCell.tsx index 82cf809a..536759ec 100644 --- a/src/screens/Notes/NoteCell.tsx +++ b/src/screens/Notes/NoteCell.tsx @@ -72,7 +72,7 @@ export const NoteCell = ({ () => { changeNote(mutator => { mutator.trashed = true; - }); + }, false); }, undefined ); @@ -120,7 +120,7 @@ export const NoteCell = ({ callback: () => changeNote(mutator => { mutator.pinned = !note.pinned; - }), + }, false), }); options.push({ @@ -138,7 +138,7 @@ export const NoteCell = ({ changeNote(mutator => { mutator.archived = !note.archived; - }); + }, false); }, }); @@ -148,7 +148,7 @@ export const NoteCell = ({ callback: () => changeNote(mutator => { mutator.locked = !note.locked; - }), + }, false), }); options.push({ @@ -172,7 +172,7 @@ export const NoteCell = ({ callback: () => { changeNote(mutator => { mutator.trashed = false; - }); + }, false); }, }, { diff --git a/src/screens/Settings/Sections/OptionsSection.tsx b/src/screens/Settings/Sections/OptionsSection.tsx index c577016f..0906429e 100644 --- a/src/screens/Settings/Sections/OptionsSection.tsx +++ b/src/screens/Settings/Sections/OptionsSection.tsx @@ -123,7 +123,7 @@ export const OptionsSection = ({ title, encryptionAvailable }: Props) => { if (!result) { return; } else if ('error' in result) { - application!.alertService!.alert(result.error); + application!.alertService!.alert(result.error.text); } else if (result.errorCount) { application!.alertService!.alert( `Import complete. ${result.errorCount} items were not imported because ` + diff --git a/src/screens/SideMenu/NoteSideMenu.tsx b/src/screens/SideMenu/NoteSideMenu.tsx index dabdeeed..3493983c 100644 --- a/src/screens/SideMenu/NoteSideMenu.tsx +++ b/src/screens/SideMenu/NoteSideMenu.tsx @@ -131,7 +131,7 @@ export const NoteSideMenu = React.memo((props: Props) => { () => { changeNote(mutator => { mutator.trashed = true; - }); + }, false); props.drawerRef?.closeDrawer(); if (!application?.getAppState().isInTabletMode) { navigation.popToTop(); @@ -246,10 +246,14 @@ export const NoteSideMenu = React.memo((props: Props) => { props.drawerRef?.closeDrawer(); if (!selectedComponent) { if (!note?.prefersPlainEditor) { - await application?.mutator.changeItem(note!.uuid, mutator => { - const noteMutator = mutator as NoteMutator; - noteMutator.prefersPlainEditor = true; - }); + await application?.mutator.changeItem( + note!.uuid, + mutator => { + const noteMutator = mutator as NoteMutator; + noteMutator.prefersPlainEditor = true; + }, + false + ); } if ( activeEditorComponent?.isExplicitlyEnabledForItem(note!.uuid) || @@ -264,10 +268,14 @@ export const NoteSideMenu = React.memo((props: Props) => { } const prefersPlain = note!.prefersPlainEditor; if (prefersPlain) { - await application?.mutator.changeItem(note!.uuid, mutator => { - const noteMutator = mutator as NoteMutator; - noteMutator.prefersPlainEditor = false; - }); + await application?.mutator.changeItem( + note!.uuid, + mutator => { + const noteMutator = mutator as NoteMutator; + noteMutator.prefersPlainEditor = false; + }, + false + ); } await associateComponentWithNote(application, selectedComponent, note); } @@ -429,7 +437,7 @@ export const NoteSideMenu = React.memo((props: Props) => { const pinEvent = () => changeNote(mutator => { mutator.pinned = !note.pinned; - }); + }, false); const archiveOption = note.archived ? 'Unarchive' : 'Archive'; const archiveEvent = () => { @@ -441,7 +449,7 @@ export const NoteSideMenu = React.memo((props: Props) => { } changeNote(mutator => { mutator.archived = !note.archived; - }); + }, false); leaveEditor(); }; @@ -449,7 +457,7 @@ export const NoteSideMenu = React.memo((props: Props) => { const lockEvent = () => changeNote(mutator => { mutator.locked = !note.locked; - }); + }, false); const protectOption = note.protected ? 'Unprotect' : 'Protect'; const protectEvent = async () => await protectOrUnprotectNote(); @@ -516,7 +524,7 @@ export const NoteSideMenu = React.memo((props: Props) => { onSelect: () => { changeNote(mutator => { mutator.trashed = false; - }); + }, false); }, }, { diff --git a/yarn.lock b/yarn.lock index 231f2c4b..3a7713cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1952,10 +1952,10 @@ resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.7.3.tgz#1e62a14800393be44cdb376d1d72fbc064334fc1" integrity sha512-twwYeBL+COkNF9IUM5bWrLZ4gXjg41tRxBMR3r3JcbrkyYjcNqVHf9L+YdBcndjSV3/9xwWl2pYWK1RB3UR2Xg== -"@standardnotes/snjs@2.89.4": - version "2.89.4" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.89.4.tgz#b7257bca0ad16de98e4f4b55e65a59481d069416" - integrity sha512-rT+H7dzimvMLjTpbI4eukIAfpcveKXBgraDnPqNTY8c7638attdXG0wmjwCa2S09VHElnBqMUq054dqOmBvVnQ== +"@standardnotes/snjs@2.90.0": + version "2.90.0" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.90.0.tgz#87f11c52d8511ee7c0939f021b5ce96f47748222" + integrity sha512-3AilDSB7FdqxPP25zf41PoHZ0iqd6dcuzT4qtYkLTGnAz/WaCLzJy0sS/e5x9tHW3sltoVRhXJsRRmQV5JZFCQ== dependencies: "@standardnotes/applications" "^1.2.6" "@standardnotes/auth" "^3.17.11"