From bda6282ebf71a03bb484dfb575d8b3895f4fdcbe Mon Sep 17 00:00:00 2001 From: Radek Czemerys Date: Wed, 13 Jan 2021 23:20:08 +0100 Subject: [PATCH] feature: update snjs & webview Update backups service for https://github.com/standardnotes/snjs/pull/178 --- ios/Podfile.lock | 8 ++--- package.json | 10 +++--- src/lib/backups_service.ts | 17 ++++++---- src/screens/Compose/Compose.tsx | 24 +++++++++----- yarn.lock | 59 ++++++++++++++++++--------------- 5 files changed, 66 insertions(+), 52 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index b7a4ffe4..da5af44b 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,6 +1,6 @@ PODS: - boost-for-react-native (1.63.0) - - BugsnagReactNative (7.5.5): + - BugsnagReactNative (7.5.6): - React - DoubleConversion (1.1.6) - FBLazyVector (0.63.4) @@ -201,7 +201,7 @@ PODS: - React-Core - react-native-version-info (1.1.0): - React-Core - - react-native-webview (10.10.2): + - react-native-webview (11.0.3): - React-Core - React-RCTActionSheet (0.63.4): - React-Core/RCTActionSheetHeaders (= 0.63.4) @@ -465,7 +465,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c - BugsnagReactNative: 722e3508bb4aadf5e9a5ef11f2195983ace1108a + BugsnagReactNative: 1ac1129bdf95273df07cfe4d89750dc3d9d888a3 DoubleConversion: cde416483dac037923206447da6e1454df403714 FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e @@ -488,7 +488,7 @@ SPEC CHECKSUMS: react-native-segmented-control: 65df6cd0619b780b3843d574a72d4c7cec396097 react-native-sodium: 6cc4c4c1ea331f9f2b478076e983e09827a7b23f react-native-version-info: 36490da17d2c6b5cc21321c70e433784dee7ed0b - react-native-webview: 0aa2cde4ee7e3e1c5fffdf64dbce9c709aa18155 + react-native-webview: 21fdfbdd5a2268195ca013174f8f656f3509de50 React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336 React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b React-RCTBlob: a97d378b527740cc667e03ebfa183a75231ab0f0 diff --git a/package.json b/package.json index 9e094846..89c163ee 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test": "jest" }, "dependencies": { - "@bugsnag/react-native": "^7.5.5", + "@bugsnag/react-native": "^7.5.6", "@expo/react-native-action-sheet": "^3.8.0", "@react-native-community/async-storage": "1.12.1", "@react-native-community/masked-view": "^0.1.10", @@ -26,7 +26,7 @@ "@react-navigation/native": "^5.8.10", "@react-navigation/stack": "^5.12.8", "@standardnotes/sncrypto-common": "1.2.9", - "@standardnotes/snjs": "2.0.35", + "@standardnotes/snjs": "2.0.39", "js-base64": "^3.5.2", "moment": "^2.29.1", "react": "16.13.1", @@ -53,8 +53,8 @@ "react-native-tab-view": "^2.15.2", "react-native-vector-icons": "^7.1.0", "react-native-version-info": "^1.1.0", - "react-native-webview": "^10.10.2", - "react-navigation-header-buttons": "^6.0.0", + "react-native-webview": "^11.0.3", + "react-navigation-header-buttons": "^6.0.2", "sn-textview": "standardnotes/sn-textview#3b56f5c2c87c24370f00ee5a0cee0da9a9fc66c3", "standard-notes-rn": "standardnotes/standard-notes-rn#996b016", "styled-components": "^5.2.1" @@ -84,7 +84,7 @@ "metro-react-native-babel-preset": "^0.60.0", "npm-run-all": "^4.1.5", "postinstall-postinstall": "^2.1.0", - "prettier": "^2.2.0", + "prettier": "^2.2.1", "prettier-plugin-organize-imports": "^1.1.1", "react-test-renderer": "16.13.1", "replace-in-file": "^6.1.0", diff --git a/src/lib/backups_service.ts b/src/lib/backups_service.ts index 4e0bd1ea..c3a8110e 100644 --- a/src/lib/backups_service.ts +++ b/src/lib/backups_service.ts @@ -23,24 +23,27 @@ export class BackupsService extends ApplicationService { async export(encrypted: boolean) { const data = await this.application!.createBackupFile( - undefined, encrypted ? EncryptionIntent.FileEncrypted - : EncryptionIntent.FileDecrypted, - true + : EncryptionIntent.FileDecrypted ); + const prettyPrint = 2; + const stringifiedData = JSON.stringify(data, null, prettyPrint); const modifier = encrypted ? 'Encrypted' : 'Decrypted'; const filename = `Standard Notes ${modifier} Backup - ${this._formattedDate()}.txt`; if (data) { if (this.application?.platform === Platform.Ios) { - return this._exportIOS(filename, data); + return this._exportIOS(filename, stringifiedData); } else { const result = await this._showAndroidEmailOrSaveOption(); if (result === 'email') { - return this._exportViaEmailAndroid(Base64.encodeURI(data), filename); + return this._exportViaEmailAndroid( + Base64.encodeURI(stringifiedData), + filename + ); } else if (result === 'save') { - let filepath = await this._exportAndroid(filename, data); + let filepath = await this._exportAndroid(filename, stringifiedData); return this._showFileSavePromptAndroid(filepath); } else { return; @@ -145,7 +148,7 @@ export class BackupsService extends ApplicationService { // On Android the Mailer callback event isn't always triggered. setTimeout(function () { if (!resolved) { - resolve(); + resolve(true); } }, 2500); }); diff --git a/src/screens/Compose/Compose.tsx b/src/screens/Compose/Compose.tsx index 70e7641d..6bd3349a 100644 --- a/src/screens/Compose/Compose.tsx +++ b/src/screens/Compose/Compose.tsx @@ -54,9 +54,9 @@ export class Compose extends React.Component<{}, State> { static contextType = ApplicationContext; context: React.ContextType; editorViewRef: React.RefObject = createRef(); - saveTimeoutRef: number | undefined; + saveTimeout: number | undefined; alreadySaved: boolean = false; - statusTimeoutRef: number | undefined; + statusTimeout: number | undefined; removeEditorObserver?: () => void; removeEditorNoteValueChangeObserver?: () => void; removeComponentsObserver?: () => void; @@ -232,14 +232,20 @@ export class Compose extends React.Component<{}, State> { this.removeEditorNoteValueChangeObserver = undefined; this.dismissKeyboard(); this.context?.getStatusManager()?.setMessage(SCREEN_COMPOSE, ''); + if (this.saveTimeout) { + clearTimeout(this.saveTimeout); + } + if (this.statusTimeout) { + clearTimeout(this.statusTimeout); + } } setStatus = (status: string, color?: string, wait: boolean = true) => { - if (this.statusTimeoutRef) { - clearTimeout(this.statusTimeoutRef); + if (this.statusTimeout) { + clearTimeout(this.statusTimeout); } if (wait) { - this.statusTimeoutRef = setTimeout(() => { + this.statusTimeout = setTimeout(() => { this.context ?.getStatusManager() ?.setMessage(SCREEN_COMPOSE, status, color); @@ -298,7 +304,7 @@ export class Compose extends React.Component<{}, State> { } else if (associatedEditor.uuid !== this.state.editorComponent?.uuid) { await this.context?.componentGroup.activateComponent(associatedEditor); } - console.log('contextItemDidChangeInArea'); + this.context?.componentManager!.contextItemDidChangeInArea( ComponentArea.Editor ); @@ -351,14 +357,14 @@ export class Compose extends React.Component<{}, State> { isUserModified ); - if (this.saveTimeoutRef) { - clearTimeout(this.saveTimeoutRef); + if (this.saveTimeout) { + clearTimeout(this.saveTimeout); } const noDebounce = bypassDebouncer || this.context?.noAccount(); const syncDebouceMs = noDebounce ? SAVE_TIMEOUT_NO_DEBOUNCE : SAVE_TIMEOUT_DEBOUNCE; - this.saveTimeoutRef = setTimeout(() => { + this.saveTimeout = setTimeout(() => { this.context?.sync(); if (closeAfterSync) { this.context?.getAppState().closeEditor(this.editor!); diff --git a/yarn.lock b/yarn.lock index 4c363baa..866b3d5e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -746,10 +746,10 @@ resolved "https://registry.yarnpkg.com/@bugsnag/delivery-react-native/-/delivery-react-native-7.5.4.tgz#6eb3b12723fea2f0aa2331696c4a27abda2ebb90" integrity sha512-w87iLxx3bcBUAm1Odn2ORGohHrJ6WlxX//+Mw6OG1FEq/uvR9TDVMznxjkb1hdEY+8A8qVeCmyUAbu1J5eCSmg== -"@bugsnag/plugin-console-breadcrumbs@^7.5.4": - version "7.5.4" - resolved "https://registry.yarnpkg.com/@bugsnag/plugin-console-breadcrumbs/-/plugin-console-breadcrumbs-7.5.4.tgz#62e6eb56c082bc2f60defd4ffea9d189b234526d" - integrity sha512-dYXyIJICQ8qTGKrW3HVLF3kHg/pOfIrqqUEAyDTMnmLzJRTNyLnF8EdS4Fa/lvuFWEJ0AmNioUjESABQwdEhbw== +"@bugsnag/plugin-console-breadcrumbs@^7.5.6": + version "7.5.6" + resolved "https://registry.yarnpkg.com/@bugsnag/plugin-console-breadcrumbs/-/plugin-console-breadcrumbs-7.5.6.tgz#885c7a2e24a33f637f04e254ecd5e1af298d358c" + integrity sha512-r1pQ//s7/k8ESoLtiL/u+I3dWxTY8g9PTnsXivY2jnZ2PgOV8QmxSWemh11Vaz3hz0x23vH1UvEiRgRBtllH4w== "@bugsnag/plugin-network-breadcrumbs@^7.5.4": version "7.5.4" @@ -786,21 +786,21 @@ resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react-native-unhandled-rejection/-/plugin-react-native-unhandled-rejection-7.5.4.tgz#e707ab7c1ea5dda1256366dafc04f3ec6b03f8fe" integrity sha512-8Poy9MxM/uAlcoPbaKWb9sjk92eN5UKmzjdnjLKwmoUmVIx60wwBd6HdrAwJ7ubA+oc7KYyqK85pvgpEKuAhzA== -"@bugsnag/plugin-react@^7.5.4": - version "7.5.4" - resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react/-/plugin-react-7.5.4.tgz#3fdd9a54d8170fbcdd99cfbd19d19628cf7ad582" - integrity sha512-UFNCae2BbvvetIegAy+h45jlmtQ8k+ZnhpM0wnG4EPzDeZA1AFM+LzqRMWF7GrRRLb8H3W8PoswUN9M1Vr6eog== +"@bugsnag/plugin-react@^7.5.6": + version "7.5.6" + resolved "https://registry.yarnpkg.com/@bugsnag/plugin-react/-/plugin-react-7.5.6.tgz#001d19edb51d1d8b618f9d2bf16e4affb539a60c" + integrity sha512-O/kvW51JngthJn09RAcv6TUkCiiv8h3PkL3rZ2P+WhjHamh3UQw4qKEQE8ICtxKip6wFANhuZermZBl0s9AMzw== -"@bugsnag/react-native@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@bugsnag/react-native/-/react-native-7.5.5.tgz#5ba83b53c5c1e92acd15df290be57e15a332e6be" - integrity sha512-f2DapB8YjYcb2bjzYSdP3uJt0hzOudHxtGzjhMRVzcLv1AY2LvNSrD2karaX8MYKtM23Fs5K8G72DUBjk/cBUQ== +"@bugsnag/react-native@^7.5.6": + version "7.5.6" + resolved "https://registry.yarnpkg.com/@bugsnag/react-native/-/react-native-7.5.6.tgz#dc74b41acb4ebf9ae0ddeb020d4035827148b8f2" + integrity sha512-5IZrimHeoBYGDPn41OLBFloaCqSNLE3+RF9YZkk3wRyElftiBM9d+0EimU0gYmkF1nCjy5j0ssp1vVofWYCoaA== dependencies: "@bugsnag/core" "^7.5.4" "@bugsnag/delivery-react-native" "^7.5.4" - "@bugsnag/plugin-console-breadcrumbs" "^7.5.4" + "@bugsnag/plugin-console-breadcrumbs" "^7.5.6" "@bugsnag/plugin-network-breadcrumbs" "^7.5.4" - "@bugsnag/plugin-react" "^7.5.4" + "@bugsnag/plugin-react" "^7.5.6" "@bugsnag/plugin-react-native-client-sync" "^7.5.4" "@bugsnag/plugin-react-native-event-sync" "^7.5.4" "@bugsnag/plugin-react-native-global-error-handler" "^7.5.4" @@ -1385,10 +1385,10 @@ resolved "https://registry.yarnpkg.com/@standardnotes/sncrypto-common/-/sncrypto-common-1.2.9.tgz#5212a959e4ec563584e42480bfd39ef129c3cbdf" integrity sha512-xJ5IUGOZztjSgNP/6XL+Ut5+q9UgSTv6xMtKkcQC5aJxCOkJy9u6RamPLdF00WQgwibxx2tu0e43bKUjTgzMig== -"@standardnotes/snjs@2.0.35": - version "2.0.35" - resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.35.tgz#9e9c3058ebbfc9af7a5fc3ae18497f02a9b1e71b" - integrity sha512-uA4HXorgiV8yFGN1dtO52istUudnc3ZzEQiFLgf0bkKvA0wH3Xt+R9bBviYAdIBkTBKHCyGsBdsCiKr1QS/X9g== +"@standardnotes/snjs@2.0.39": + version "2.0.39" + resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.39.tgz#ecdcecabf575eac1614196897529254e501d2f83" + integrity sha512-ZtzjApW3UNKUgC1e3y/Dcpd8Z7D1kWxK4Am2DTj8U2GpKt/1vnADyHx4nEJqYU4lfbTsMx2ULBqg3i2ZCe8/hg== dependencies: "@standardnotes/sncrypto-common" "^1.2.9" @@ -6634,11 +6634,16 @@ prettier-plugin-organize-imports@^1.1.1: resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-1.1.1.tgz#7f1ac1a13d4d1752dc16881894dde1c10ccbf3c0" integrity sha512-rFA1lnek1FYkMGthm4xBKME41qUKItTovuo24bCGZu/Vu1n3gW71UPLAkIdwewwkZCe29gRVweSOPXvAdckFuw== -prettier@^2.0.2, prettier@^2.2.0: +prettier@^2.0.2: version "2.2.0" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.0.tgz#8a03c7777883b29b37fb2c4348c66a78e980418b" integrity sha512-yYerpkvseM4iKD/BXLYUkQV5aKt4tQPqaGW6EsZjzyu0r7sVZZNPJW4Y8MyKmicp6t42XUPcBVA+H6sB3gqndw== +prettier@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== + pretty-format@^24.7.0, pretty-format@^24.9.0: version "24.9.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" @@ -6925,10 +6930,10 @@ react-native-version-info@^1.1.0: resolved "https://registry.yarnpkg.com/react-native-version-info/-/react-native-version-info-1.1.0.tgz#1407de863cae4dbbeeadb9c173a295a7774b6884" integrity sha512-0QmJjdKyaW+G/TiOWkwzGVv1G3FPnWrPH5SYWloUpv8WA7onuQESYHdLyjfCUInYI/FHVeEynE2VomOOsda8wQ== -react-native-webview@^10.10.2: - version "10.10.2" - resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-10.10.2.tgz#13208aef17c9ccfd28355363688f4cbe2143f10a" - integrity sha512-98Dh7q1gEflicFZ8KNL3nK5XRjx50OZXqw87jHofVjKfjbK0LKmvI5X8ymgUMGg61JVgI3AF+g8qpDvqjgQsfg== +react-native-webview@^11.0.3: + version "11.0.3" + resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-11.0.3.tgz#7235ee46d3df30443734bd5e5ba3c28588413e83" + integrity sha512-or0MP5JthBGXX1/MNePdR7NC0LJXtr1F0yb0wrvEZ0iqSl1xh4yJ4s225qpkPdq3m8bDWMUpM0FGKad26rddOg== dependencies: escape-string-regexp "2.0.0" invariant "2.2.4" @@ -6966,10 +6971,10 @@ react-native@0.63.4: use-subscription "^1.0.0" whatwg-fetch "^3.0.0" -react-navigation-header-buttons@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/react-navigation-header-buttons/-/react-navigation-header-buttons-6.0.0.tgz#6e58d58b8aa6e2d058729ca8dad52c5ee5742f47" - integrity sha512-m9pbT7dpi0PWqInhepIovkyYatb08Oz4l9zDx6Qt43QqO/jPRhIHtS15NNGziam+XiAn/9gHyOTKe3Fsh0BqYA== +react-navigation-header-buttons@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/react-navigation-header-buttons/-/react-navigation-header-buttons-6.0.2.tgz#7d3d1a30b197be4a0ae8dd9a0d8dd5f573ad48ee" + integrity sha512-osljWOv5qlY7FymJ6WET4AA/i3QkY8QGHtewYyfDVJ68C2BeL3sQOD/8d6uqmQ3m+vJYAAIz8GQCpoIx+D84Vg== dependencies: invariant ">=2"