diff --git a/apps/mobile/App.js b/apps/mobile/App.js index 39a51cfd8..d77335863 100644 --- a/apps/mobile/App.js +++ b/apps/mobile/App.js @@ -1,12 +1,10 @@ -import React, {useEffect, useState} from 'react'; -import {View} from 'react-native'; +import React, {useEffect} from 'react'; import Orientation from 'react-native-orientation'; -import Animated, {Easing} from 'react-native-reanimated'; -import AnimatedProgress from 'react-native-reanimated-progress-bar'; import {SafeAreaProvider} from 'react-native-safe-area-context'; import SplashScreen from 'react-native-splash-screen'; import {AppRootEvents} from './AppRootEvents'; import {RootView} from './initializer.root'; +import AppLoader from './src/components/AppLoader'; import {useTracked} from './src/provider'; import {Actions} from './src/provider/Actions'; import {DDS} from './src/services/DeviceDetection'; @@ -15,19 +13,11 @@ import { eSubscribeEvent, eUnSubscribeEvent, } from './src/services/EventManager'; -import Navigation from './src/services/Navigation'; import SettingsService from './src/services/SettingsService'; -import { - changeAppScale, - changeContainerScale, - ContainerScale, -} from './src/utils/Animations'; import {db} from './src/utils/DB'; import {eDispatchAction, eOpenSideMenu} from './src/utils/Events'; -import {sleep} from './src/utils/TimeUtils'; import EditorRoot from './src/views/Editor/EditorRoot'; - let initStatus = false; const App = () => { const [, dispatch] = useTracked(); @@ -35,8 +25,6 @@ const App = () => { useEffect(() => { (async () => { try { - scaleV.setValue(0.95); - opacityV.setValue(1); Orientation.getOrientation((e, r) => { DDS.checkSmallTab(r); dispatch({ @@ -84,95 +72,9 @@ const App = () => { - + ); }; export default App; - -const scaleV = new Animated.Value(0.95); -const opacityV = new Animated.Value(1); -const Overlay = ({onLoad}) => { - const [state, dispatch] = useTracked(); - const colors = state.colors; - const [loading, setLoading] = useState(true); - const [progress, setProgress] = useState(4); - const [opacity, setOpacity] = useState(true); - - const load = async () => { - db.notes.init().then(() => { - init = true; - dispatch({type: Actions.NOTES}); - dispatch({type: Actions.FAVORITES}); - dispatch({type: Actions.LOADING, loading: false}); - eSendEvent(eOpenSideMenu); - }); - setOpacity(false); - await sleep(150); - eSendEvent(eOpenSideMenu); - Animated.timing(opacityV, { - toValue: 0, - duration: 150, - easing: Easing.out(Easing.ease), - }).start(); - Animated.timing(scaleV, { - toValue: 1, - duration: 150, - easing: Easing.out(Easing.ease), - }).start(); - changeContainerScale(ContainerScale, 1, 500); - await sleep(150); - setLoading(false); - animation = false; - }; - - useEffect(() => { - eSubscribeEvent('load_overlay', load); - onLoad(); - return () => { - eUnSubscribeEvent('load_overlay', load); - }; - }, []); - - return ( - loading && ( - - { - setLoading(false); - }} - style={{ - backgroundColor: colors.bg, - width: '100%', - height: '100%', - justifyContent: 'center', - alignItems: 'center', - borderRadius: 10, - opacity: opacityV, - }}> - - - - - - ) - ); -}; diff --git a/apps/mobile/android/app/src/main/assets/compressor.min.js b/apps/mobile/android/app/src/main/assets/compressor.min.js new file mode 100644 index 000000000..2dfb18a3d --- /dev/null +++ b/apps/mobile/android/app/src/main/assets/compressor.min.js @@ -0,0 +1,10 @@ +/*! + * Compressor.js v1.0.7 + * https://fengyuanchen.github.io/compressorjs + * + * Copyright 2018-present Chen Fengyuan + * Released under the MIT license + * + * Date: 2020-11-28T07:13:17.754Z + */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Compressor=t()}(this,function(){"use strict";function n(e,t){for(var r=0;rf.convertSize&&"image/png"===f.mimeType&&(v="#fff",f.mimeType="image/jpeg"),m.fillStyle=v,m.fillRect(0,0,o,e),f.beforeDraw&&f.beforeDraw.call(this,m,d),this.aborted||(m.save(),m.translate(o/2,e/2),m.rotate(i*Math.PI/180),m.scale(l,c),m.drawImage(h,w,g,n,y),m.restore(),f.drew&&f.drew.call(this,m,d),this.aborted||(m=function(e){t.aborted||t.done({naturalWidth:r,naturalHeight:a,result:e})},d.toBlob?d.toBlob(m,f.mimeType,f.quality):m(U(d.toDataURL(f.mimeType,f.quality)))))}},{key:"done",value:function(e){var t=e.naturalWidth,r=e.naturalHeight,a=e.result,n=this.file,i=this.image,e=this.options;g&&!e.checkOrientation&&g.revokeObjectURL(i.src),!a||e.strict&&a.size>n.size&&e.mimeType===n.type&&!(e.width>t||e.height>r||e.minWidth>t||e.minHeight>r)?a=n:(r=new Date,a.lastModified=r.getTime(),a.lastModifiedDate=r,a.name=n.name,a.name&&a.type!==n.type&&(a.name=a.name.replace(y,("jpeg"===(n=B(n=a.type)?n.substr(6):"")&&(n="jpg"),".".concat(n))))),this.result=a,e.success&&e.success.call(this,a)}},{key:"fail",value:function(e){var t=this.options;if(!t.error)throw e;t.error.call(this,e)}},{key:"abort",value:function(){this.aborted||(this.aborted=!0,this.reader?this.reader.abort():this.image.complete?this.fail(new Error("The compression process has been aborted.")):(this.image.onload=null,this.image.onabort()))}}])&&n(e.prototype,t),a&&n(e,a),r}()}); \ No newline at end of file diff --git a/apps/mobile/android/app/src/main/assets/constants.js b/apps/mobile/android/app/src/main/assets/constants.js index b906f7396..9b552aa93 100644 --- a/apps/mobile/android/app/src/main/assets/constants.js +++ b/apps/mobile/android/app/src/main/assets/constants.js @@ -22,55 +22,54 @@ let pageTheme = { }; const markdownPatterns = [ - { start: "*", end: "*", format: "italic" }, - { start: "**", end: "**", format: "bold" }, - { start: "`", end: "`", format: "code" }, - { start: "#", format: "h1" }, - { start: "##", format: "h2" }, - { start: "###", format: "h3" }, - { start: "####", format: "h4" }, - { start: "#####", format: "h5" }, - { start: "######", format: "h6" }, - { start: "* ", cmd: "InsertUnorderedList" }, - { start: "- ", cmd: "InsertUnorderedList" }, - { start: "> ", format: "blockquote" }, + {start: '*', end: '*', format: 'italic'}, + {start: '**', end: '**', format: 'bold'}, + {start: '`', end: '`', format: 'code'}, + {start: '#', format: 'h1'}, + {start: '##', format: 'h2'}, + {start: '###', format: 'h3'}, + {start: '####', format: 'h4'}, + {start: '#####', format: 'h5'}, + {start: '######', format: 'h6'}, + {start: '* ', cmd: 'InsertUnorderedList'}, + {start: '- ', cmd: 'InsertUnorderedList'}, + {start: '> ', format: 'blockquote'}, { - start: "1. ", - cmd: "InsertOrderedList", - value: { "list-style-type": "decimal" }, + start: '1. ', + cmd: 'InsertOrderedList', + value: {'list-style-type': 'decimal'}, }, { - start: "1) ", - cmd: "InsertOrderedList", - value: { "list-style-type": "decimal" }, + start: '1) ', + cmd: 'InsertOrderedList', + value: {'list-style-type': 'decimal'}, }, { - start: "a. ", - cmd: "InsertOrderedList", - value: { "list-style-type": "lower-alpha" }, + start: 'a. ', + cmd: 'InsertOrderedList', + value: {'list-style-type': 'lower-alpha'}, }, { - start: "a) ", - cmd: "InsertOrderedList", - value: { "list-style-type": "lower-alpha" }, + start: 'a) ', + cmd: 'InsertOrderedList', + value: {'list-style-type': 'lower-alpha'}, }, { - start: "i. ", - cmd: "InsertOrderedList", - value: { "list-style-type": "lower-roman" }, + start: 'i. ', + cmd: 'InsertOrderedList', + value: {'list-style-type': 'lower-roman'}, }, { - start: "i) ", - cmd: "InsertOrderedList", - value: { "list-style-type": "lower-roman" }, + start: 'i) ', + cmd: 'InsertOrderedList', + value: {'list-style-type': 'lower-roman'}, }, - { start: "---", replacement: "
" }, - { start: "--", replacement: "—" }, - { start: "-", replacement: "—" }, - { start: "(c)", replacement: "©" }, + {start: '---', replacement: '
'}, + {start: '--', replacement: '—'}, + {start: '-', replacement: '—'}, + {start: '(c)', replacement: '©'}, ]; - function dark() { if (!tinymce.activeEditor) return; tinymce.activeEditor.dom.styleSheetLoader.unload( @@ -144,22 +143,24 @@ var minifyImg = function ( resolve, imageArguments = 0.7, ) { - var image, oldWidth, oldHeight, newHeight, canvas, ctx, newDataUrl; - new Promise(function (resolve) { - image = new Image(); - image.src = dataUrl; - resolve('Done : '); - }).then((d) => { - oldWidth = image.width; - oldHeight = image.height; - newHeight = Math.floor((oldHeight / oldWidth) * newWidth); - canvas = document.createElement('canvas'); - canvas.width = newWidth; - canvas.height = newHeight; - ctx = canvas.getContext('2d'); - ctx.drawImage(image, 0, 0, newWidth, newHeight); - newDataUrl = canvas.toDataURL(undefined, imageArguments); - resolve(newDataUrl); + fetch(dataUrl).then(async (res) => { + let blob = await res.blob(); + new Compressor(blob, { + quality: imageArguments, + width: newWidth, + mimeType:imageType, + success: (result) => { + let fileReader = new FileReader(); + fileReader.onloadend = function () { + resolve(fileReader.result); + fileReader.onloadend = null; + }; + fileReader.readAsDataURL(result); + }, + error: (err) => { + console.log(err.message); + }, + }); }); }; @@ -173,13 +174,13 @@ function loadImage() { console.log(e, 'loaded error'); minifyImg( reader.result, - 600, + 1024, 'image/jpeg', (r) => { var content = ``; editor.insertContent(content); }, - 0.7, + 0.6, ); fileInput.removeEventListener('change', listener); reader.removeEventListener('load', load); diff --git a/apps/mobile/android/app/src/main/assets/index.html b/apps/mobile/android/app/src/main/assets/index.html index a3c686ab3..a33efa6b6 100644 --- a/apps/mobile/android/app/src/main/assets/index.html +++ b/apps/mobile/android/app/src/main/assets/index.html @@ -25,19 +25,19 @@ Powered by Tiny - + + diff --git a/apps/mobile/android/app/src/main/assets/init.js b/apps/mobile/android/app/src/main/assets/init.js index 820cc58e8..824913b25 100644 --- a/apps/mobile/android/app/src/main/assets/init.js +++ b/apps/mobile/android/app/src/main/assets/init.js @@ -21,15 +21,15 @@ function init_tiny(size) { skin_url: 'dist/skins/notesnook', content_css: 'dist/skins/notesnook', plugins: [ - "mychecklist advlist autolink textpattern hr lists link noneditable image", - "searchreplace mycode", - "media imagetools table paste wordcount autoresize directionality", + 'mychecklist advlist autolink textpattern hr lists link noneditable image', + 'searchreplace mycode', + 'media imagetools table paste wordcount autoresize directionality', ], toolbar: false, paste_data_images: true, - images_upload_handler: function (blobInfo, success, failure) { + /* images_upload_handler: function (blobInfo, success, failure) { success('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64()); - }, + }, */ statusbar: false, textpattern_patterns: markdownPatterns, contextmenu: false, @@ -43,6 +43,24 @@ function init_tiny(size) { pre.codeblock { overflow-x:auto; } + img { + max-width:100% !important; + height:auto !important; + } + iframe { + max-width:100% !important; + } + table { + display: block !important; + overflow-x: auto !important; + white-space: nowrap !important; + max-width:100% !important; + width:100% !important; + height:auto !important; + } + td { + min-width:20vw !important; + } `, browser_spellcheck: true, autoresize_bottom_margin: 120, @@ -74,7 +92,7 @@ function init_tiny(size) { editor.on('SetContent', (event) => { if (!event.paste) { reactNativeEventHandler('noteLoaded', true); - } + } if (event.paste) { isLoading = false; onChange(event); @@ -95,10 +113,8 @@ function init_tiny(size) { } window.prevContent = ""; const onChange = (event) => { - if (event.type === "nodechange" && !event.selectionChange) return; - if (editor.getContent() === window.prevContent) return; - window.prevContent = editor.getContent(); - + if (event.type === 'nodechange' && !event.selectionChange) return; + if (isLoading) { isLoading = false; return; diff --git a/apps/mobile/html/Web.bundle/site/compressor.min.js b/apps/mobile/html/Web.bundle/site/compressor.min.js new file mode 100644 index 000000000..2dfb18a3d --- /dev/null +++ b/apps/mobile/html/Web.bundle/site/compressor.min.js @@ -0,0 +1,10 @@ +/*! + * Compressor.js v1.0.7 + * https://fengyuanchen.github.io/compressorjs + * + * Copyright 2018-present Chen Fengyuan + * Released under the MIT license + * + * Date: 2020-11-28T07:13:17.754Z + */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Compressor=t()}(this,function(){"use strict";function n(e,t){for(var r=0;rf.convertSize&&"image/png"===f.mimeType&&(v="#fff",f.mimeType="image/jpeg"),m.fillStyle=v,m.fillRect(0,0,o,e),f.beforeDraw&&f.beforeDraw.call(this,m,d),this.aborted||(m.save(),m.translate(o/2,e/2),m.rotate(i*Math.PI/180),m.scale(l,c),m.drawImage(h,w,g,n,y),m.restore(),f.drew&&f.drew.call(this,m,d),this.aborted||(m=function(e){t.aborted||t.done({naturalWidth:r,naturalHeight:a,result:e})},d.toBlob?d.toBlob(m,f.mimeType,f.quality):m(U(d.toDataURL(f.mimeType,f.quality)))))}},{key:"done",value:function(e){var t=e.naturalWidth,r=e.naturalHeight,a=e.result,n=this.file,i=this.image,e=this.options;g&&!e.checkOrientation&&g.revokeObjectURL(i.src),!a||e.strict&&a.size>n.size&&e.mimeType===n.type&&!(e.width>t||e.height>r||e.minWidth>t||e.minHeight>r)?a=n:(r=new Date,a.lastModified=r.getTime(),a.lastModifiedDate=r,a.name=n.name,a.name&&a.type!==n.type&&(a.name=a.name.replace(y,("jpeg"===(n=B(n=a.type)?n.substr(6):"")&&(n="jpg"),".".concat(n))))),this.result=a,e.success&&e.success.call(this,a)}},{key:"fail",value:function(e){var t=this.options;if(!t.error)throw e;t.error.call(this,e)}},{key:"abort",value:function(){this.aborted||(this.aborted=!0,this.reader?this.reader.abort():this.image.complete?this.fail(new Error("The compression process has been aborted.")):(this.image.onload=null,this.image.onabort()))}}])&&n(e.prototype,t),a&&n(e,a),r}()}); \ No newline at end of file diff --git a/apps/mobile/html/Web.bundle/site/constants.js b/apps/mobile/html/Web.bundle/site/constants.js index b906f7396..40fca3813 100644 --- a/apps/mobile/html/Web.bundle/site/constants.js +++ b/apps/mobile/html/Web.bundle/site/constants.js @@ -136,7 +136,6 @@ function setTheme() { css.appendChild(document.createTextNode(node)); document.getElementsByTagName('head')[0].appendChild(css); } - var minifyImg = function ( dataUrl, newWidth, @@ -144,22 +143,24 @@ var minifyImg = function ( resolve, imageArguments = 0.7, ) { - var image, oldWidth, oldHeight, newHeight, canvas, ctx, newDataUrl; - new Promise(function (resolve) { - image = new Image(); - image.src = dataUrl; - resolve('Done : '); - }).then((d) => { - oldWidth = image.width; - oldHeight = image.height; - newHeight = Math.floor((oldHeight / oldWidth) * newWidth); - canvas = document.createElement('canvas'); - canvas.width = newWidth; - canvas.height = newHeight; - ctx = canvas.getContext('2d'); - ctx.drawImage(image, 0, 0, newWidth, newHeight); - newDataUrl = canvas.toDataURL(undefined, imageArguments); - resolve(newDataUrl); + fetch(dataUrl).then(async (res) => { + let blob = await res.blob(); + new Compressor(blob, { + quality: imageArguments, + width: newWidth, + mimeType:imageType, + success: (result) => { + let fileReader = new FileReader(); + fileReader.onloadend = function () { + resolve(fileReader.result); + fileReader.onloadend = null; + }; + fileReader.readAsDataURL(result); + }, + error: (err) => { + console.log(err.message); + }, + }); }); }; @@ -173,13 +174,13 @@ function loadImage() { console.log(e, 'loaded error'); minifyImg( reader.result, - 600, + 1024, 'image/jpeg', (r) => { var content = ``; editor.insertContent(content); }, - 0.7, + 0.8, ); fileInput.removeEventListener('change', listener); reader.removeEventListener('load', load); diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.html index 7eb05fe76..811f607c4 100644 --- a/apps/mobile/html/Web.bundle/site/index.html +++ b/apps/mobile/html/Web.bundle/site/index.html @@ -25,13 +25,14 @@ Powered by Tiny - + + diff --git a/apps/mobile/html/Web.bundle/site/init.js b/apps/mobile/html/Web.bundle/site/init.js index 820cc58e8..452a8cfa7 100644 --- a/apps/mobile/html/Web.bundle/site/init.js +++ b/apps/mobile/html/Web.bundle/site/init.js @@ -27,9 +27,9 @@ function init_tiny(size) { ], toolbar: false, paste_data_images: true, - images_upload_handler: function (blobInfo, success, failure) { - success('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64()); - }, + // images_upload_handler: function (blobInfo, success, failure) { + // success('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64()); + // }, statusbar: false, textpattern_patterns: markdownPatterns, contextmenu: false, @@ -43,6 +43,24 @@ function init_tiny(size) { pre.codeblock { overflow-x:auto; } + img { + max-width:100% !important; + height:auto !important; + } + iframe { + max-width:100% !important; + } + table { + display: block !important; + overflow-x: auto !important; + white-space: nowrap !important; + max-width:100% !important; + width:100% !important; + height:auto !important; + } + td { + min-width:20vw !important; + } `, browser_spellcheck: true, autoresize_bottom_margin: 120, @@ -96,8 +114,7 @@ function init_tiny(size) { window.prevContent = ""; const onChange = (event) => { if (event.type === "nodechange" && !event.selectionChange) return; - if (editor.getContent() === window.prevContent) return; - window.prevContent = editor.getContent(); + if (isLoading) { isLoading = false; diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js index 0249559fa..431ef42b8 100644 --- a/apps/mobile/initializer.root.js +++ b/apps/mobile/initializer.root.js @@ -48,7 +48,7 @@ const onChangeTab = async (obj) => { currentTab = 1; activateKeepAwake(); eSendEvent('navigate'); - + eSendEvent(eClearEditor, 'addHandler'); if (!editing.currentlyEditing || !getNote()) { eSendEvent(eOnLoadNote, {type: 'new'}); editing.currentlyEditing = true; @@ -60,6 +60,7 @@ const onChangeTab = async (obj) => { if (obj.from === 1) { updateStatusBarColor(); deactivateKeepAwake(); + eSendEvent(eClearEditor, 'removeHandler'); if (getNote()?.locked) { eSendEvent(eClearEditor); } diff --git a/apps/mobile/src/assets/images/notesnook-logo-png.png b/apps/mobile/src/assets/images/notesnook-logo-png.png index 57eeb66ee..f51f3215e 100644 Binary files a/apps/mobile/src/assets/images/notesnook-logo-png.png and b/apps/mobile/src/assets/images/notesnook-logo-png.png differ diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js index 420fe878a..a9a523e18 100644 --- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js +++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js @@ -74,7 +74,7 @@ const ActionSheetWrapper = ({ return ( { const [state, dispatch] = useTracked(); - const {colors, premiumUser, user} = state; + const {colors, user} = state; const [refreshing, setRefreshing] = useState(false); const [isPinnedToMenu, setIsPinnedToMenu] = useState(false); const [note, setNote] = useState(item); + const [noteInTopic, setNoteInTopic] = useState( + editing.actionAfterFirstSave.type === 'topic' && + db.notebooks + .notebook(editing.actionAfterFirstSave.notebook) + .topics.topic(editing.actionAfterFirstSave.id) + .has(item.id), + ); function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) { let newColors = setColorScheme(colors, accent); @@ -138,12 +145,12 @@ export const ActionSheetComponent = ({ name: 'Add to', icon: 'book-outline', func: () => { + close(); dispatch({type: Actions.CLEAR_SELECTION}); dispatch({type: Actions.SELECTED_ITEMS, item: note}); - close(); setTimeout(() => { eSendEvent(eOpenMoveNoteDialog, note); - }, 400); + }, 300); }, }, { @@ -151,6 +158,7 @@ export const ActionSheetComponent = ({ icon: 'share-variant', func: async () => { if (note.locked) { + close(); openVault({ item: item, novault: true, @@ -181,8 +189,9 @@ export const ActionSheetComponent = ({ name: 'Delete', icon: 'delete', func: async () => { + close(); if (note.locked) { - close(); + await sleep(300); openVault({ deleteNote: true, @@ -194,12 +203,12 @@ export const ActionSheetComponent = ({ }); } else { try { + close(); await deleteItems(note); } catch (e) { //console.log(e); } } - close(); }, }, { @@ -246,6 +255,7 @@ export const ActionSheetComponent = ({ name: 'Restore', icon: 'delete-restore', func: async () => { + close(); await db.trash.restore(note.id); Navigation.setRoutesToUpdate([ Navigation.routeNames.Tags, @@ -264,7 +274,7 @@ export const ActionSheetComponent = ({ : 'Notebook restored from trash', type: 'success', }); - close(); + }, }, { @@ -300,6 +310,7 @@ export const ActionSheetComponent = ({ icon: 'pin', func: async () => { if (!note.id) return; + close(); if (note.type === 'note') { if (db.notes.pinned.length === 3 && !note.pinned) { ToastEvent.show({ @@ -322,7 +333,7 @@ export const ActionSheetComponent = ({ await db.notebooks.notebook(note.id).pin(); } localRefresh(item.type); - close(); + }, close: false, check: true, @@ -335,6 +346,7 @@ export const ActionSheetComponent = ({ icon: 'star', func: async () => { if (!note.id) return; + close(); if (note.type === 'note') { await db.notes.note(note.id).favorite(); } else { @@ -346,7 +358,7 @@ export const ActionSheetComponent = ({ forced: true, }); localRefresh(item.type, true); - close(); + }, close: false, check: true, @@ -361,6 +373,7 @@ export const ActionSheetComponent = ({ : 'Add Shortcut to Menu', icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant', func: async () => { + close(); try { if (isPinnedToMenu) { await db.settings.unpin(note.id); @@ -377,6 +390,7 @@ export const ActionSheetComponent = ({ setIsPinnedToMenu(db.settings.isPinned(note.id)); dispatch({type: Actions.MENU_PINS}); } catch (e) {} + }, close: false, check: true, @@ -724,11 +738,7 @@ export const ActionSheetComponent = ({ ) : null} - {editing.actionAfterFirstSave.type === 'topic' && - note.notebooks?.length > 0 && - note?.notebooks?.findIndex( - (o) => o.topics.indexOf(editing.actionAfterFirstSave.id) > -1, - ) > -1 ? ( + {noteInTopic ? ( { + const [state, dispatch] = useTracked(); + const colors = state.colors; + const [loading, setLoading] = useState(true); + const [opacity, setOpacity] = useState(true); + + const load = async () => { + eSendEvent(eOpenSideMenu); + setOpacity(false); + await sleep(2); + Animated.timing(opacityV, { + toValue: 0, + duration: 150, + easing: Easing.out(Easing.ease), + }).start(); + db.notes.init().then(() => { + dispatch({type: Actions.NOTES}); + dispatch({type: Actions.FAVORITES}); + dispatch({type: Actions.LOADING, loading: false}); + eSendEvent(eOpenSideMenu); + }); + changeContainerScale(ContainerScale, 1, 600); + await sleep(150); + setLoading(false); + animation = false; + }; + + useEffect(() => { + eSubscribeEvent('load_overlay', load); + onLoad(); + return () => { + eUnSubscribeEvent('load_overlay', load); + }; + }, []); + + return ( + loading && ( + + { + setLoading(false); + }} + style={{ + backgroundColor: colors.bg, + width: '100%', + height: '100%', + justifyContent: 'center', + alignItems: 'center', + borderRadius: 10, + opacity: opacityV, + }}> + + + + + + ) + ); +}; + +export default AppLoader; diff --git a/apps/mobile/src/components/Container/ContainerBottomButton.js b/apps/mobile/src/components/Container/ContainerBottomButton.js index 37cfb5395..164d9fdd9 100644 --- a/apps/mobile/src/components/Container/ContainerBottomButton.js +++ b/apps/mobile/src/components/Container/ContainerBottomButton.js @@ -11,17 +11,15 @@ import {normalize, SIZE} from '../../utils/SizeUtils'; import {PressableButton} from '../PressableButton'; import RNTooltips from 'react-native-tooltips'; -const translateY = new Animated.Value(0); +//const translateY = new Animated.Value(0); export const ContainerBottomButton = ({ title, onPress, color = 'accent', shouldShow = false, }) => { - const [state] = useTracked(); - const {colors} = state; const insets = useSafeAreaInsets(); - +/* function animate(translate) { Animated.timing(translateY, { toValue: translate, @@ -48,7 +46,7 @@ export const ContainerBottomButton = ({ Keyboard.removeListener('keyboardDidHide', onKeyboardHide); }; }, []); - + */ return DDS.isLargeTablet() && !shouldShow ? null : ( { return ( { marginLeft: -5, marginRight:DDS.isLargeTablet()? 10 : 25, }} + left={40} + top={40} + right={DDS.isLargeTablet()? 10 : 25} onPress={onLeftButtonPress} onLongPress={() => { Navigation.popToTop(); diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js index ac32e4659..cb44a303e 100644 --- a/apps/mobile/src/components/MoveNoteDialog/index.js +++ b/apps/mobile/src/components/MoveNoteDialog/index.js @@ -12,6 +12,7 @@ import { ToastEvent, } from '../../services/EventManager'; import Navigation from '../../services/Navigation'; +import { getTotalNotes } from '../../utils'; import {db} from '../../utils/DB'; import {eOpenMoveNoteDialog} from '../../utils/Events'; import {pv, SIZE} from '../../utils/SizeUtils'; @@ -81,7 +82,7 @@ const MoveNoteComponent = ({close, note, setNote}) => { const [expanded, setExpanded] = useState(''); const [notebookInputFocused, setNotebookInputFocused] = useState(false); const [topicInputFocused, setTopicInputFocused] = useState(false); - + const [noteExists, setNoteExists] = useState([]); const addNewNotebook = async () => { if (!newNotebookTitle || newNotebookTitle.trim().length === 0) return ToastEvent.show({ @@ -117,14 +118,7 @@ const MoveNoteComponent = ({close, note, setNote}) => { }; const handlePress = async (item, index) => { - if ( - note?.notebooks?.findIndex( - (o) => - o.topics.findIndex((i) => { - return i === item.id; - }) > -1, - ) > -1 - ) { + if (note && item.notes.indexOf(note.id) > -1) { await db.notebooks .notebook(item.notebookId) .topics.topic(item.id) @@ -163,6 +157,19 @@ const MoveNoteComponent = ({close, note, setNote}) => { dispatch({type: Actions.NOTEBOOKS}); }; + useEffect(() => { + if (!note?.id) return; + let ids = []; + for (let i = 0; i < notebooks.length; i++) { + for (let t = 0; t < notebooks[i].topics.length; t++) { + if (notebooks[i].topics[t].notes.indexOf(note.id) > -1) { + ids.push(notebooks[i].id); + } + } + } + setNoteExists(ids); + }, []); + return ( <> @@ -290,7 +297,9 @@ const MoveNoteComponent = ({close, note, setNote}) => { marginBottom: 5, borderBottomWidth: 1, borderBottomColor: - expanded === item.id ? colors.accent : colors.nav, + expanded === item.id || noteExists.indexOf(item.id) > -1 + ? colors.accent + : colors.nav, }}> { }}> -1 + ? colors.accent + : null + } size={SIZE.md}> {item.title} - Notebook{' '} - {item.totalNotes + + {getTotalNotes(item) + ' notes' + ' & ' + item.topics.length + @@ -431,12 +443,10 @@ const MoveNoteComponent = ({close, note, setNote}) => { {item.title} - {item.totalNotes + ' notes'} + {item.notes.length + ' notes'} - {note?.notebooks?.findIndex( - (o) => o.topics.indexOf(item.id) > -1, - ) > -1 ? ( + {note && item.notes.indexOf(note.id) > -1 ? (