From cfd7caf16c77b901969b920d0d01c4ac710c39e9 Mon Sep 17 00:00:00 2001 From: Nick Thomas <73144044+NickThomas20@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:19:44 -0500 Subject: [PATCH 01/13] Updated grammar readme docs: Updated grammar readme Signed-off-by: Nick Thomas nick02@iastate.edu Signed-off-by: Nick Thomas <73144044+NickThomas20@users.noreply.github.com> --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6e688e348..ef92a3044 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ ## Overview -Notesnook is a free (as in speech) & open source note taking app focused on user privacy & ease of use. To ensure zero knowledge principles, Notesnook encrypts everything on your device using `XChaCha20-Poly1305` & `Argon2`. +Notesnook is a free (as in speech) & open-source note-taking app focused on user privacy & ease of use. To ensure zero knowledge principles, Notesnook encrypts everything on your device using `XChaCha20-Poly1305` & `Argon2`. -Notesnook is our **proof** that privacy does _not_ (always) have to come at the cost of convenience. Our goal is to provide users peace of mind & 100% confidence that their notes are safe and secure. The decision to go fully open source is one of the most crucial steps towards that. +Notesnook is our **proof** that privacy does _not_ (always) have to come at the cost of convenience. We aim to provide users peace of mind & 100% confidence that their notes are safe and secure. The decision to go fully open source is one of the most crucial steps towards that. -This repository contains all the code required to build & use the Notesnook web, desktop & mobile clients. If you are looking for a full features list or screenshots, please check the [website](https://notesnook.com/). +This repository contains all the code required to build & use the Notesnook web, desktop & mobile clients. If you are looking for a full feature list or screenshots, please check the [website](https://notesnook.com/). ## Developer guide From c9a657298c29c1896a44844a127dc9df36ae8c34 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sat, 15 Apr 2023 02:01:47 +0500 Subject: [PATCH 02/13] mobile: fix crash when data is null in list --- apps/mobile/app/components/list/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/components/list/index.js b/apps/mobile/app/components/list/index.js index 495f8b323..28c3fc7bf 100644 --- a/apps/mobile/app/components/list/index.js +++ b/apps/mobile/app/components/list/index.js @@ -218,12 +218,14 @@ const List = ({ } /> - + {listData ? ( + + ) : null} ); }; From 49e79b52b22b9a7bf06b38998faa7676651e05d4 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sat, 15 Apr 2023 02:12:50 +0500 Subject: [PATCH 03/13] core: add remote note if local note does not exist --- packages/core/collections/notes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.js index 71d28555f..c04fdf66c 100644 --- a/packages/core/collections/notes.js +++ b/packages/core/collections/notes.js @@ -59,7 +59,7 @@ export default class Notes extends Collection { if ( remoteNote.deleted && remoteNote.deleteReason !== "localOnly" && - !localNote.localOnly + (!localNote || !localNote.localOnly) ) return await this._collection.addItem(remoteNote); From 1da5fd36617eca338be9e1e106b0cbe8c2e69099 Mon Sep 17 00:00:00 2001 From: NedimHodzic <105010544+NedimHodzic@users.noreply.github.com> Date: Fri, 14 Apr 2023 19:22:18 -0500 Subject: [PATCH 04/13] docs: fix grammar issues in mobile/web READMEs (#2345) Signed-off-by: Nedim Hodzic hodzicnedim11@gmail.com --- apps/mobile/README.md | 40 ++++++++++++++++++++-------------------- apps/web/README.md | 36 ++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/apps/mobile/README.md b/apps/mobile/README.md index 8d2556674..a138a3034 100644 --- a/apps/mobile/README.md +++ b/apps/mobile/README.md @@ -19,9 +19,9 @@ ## Build instructions -> **Before you start it is recommended that you read [the contributing guidelines](/CONTRIBUTING.md).** +> **Before you start, it is recommended that you read [the contributing guidelines](/CONTRIBUTING.md).** -### Setting up development environment +### Setting up the development environment Requirements: @@ -57,7 +57,7 @@ npm install ### Running the app on Android -[Setup an Android emulator from Android Studio](https://developer.android.com/studio/run/managing-avds) if you haven't already and then run the following command to start the app in the Emulator: +[Setup an Android emulator from Android Studio](https://developer.android.com/studio/run/managing-avds) if you haven't already, and then run the following command to start the app in the Emulator: ```bash npm run start:android @@ -78,11 +78,11 @@ npm run start:ios ## Developer guide -> This project is in a transition state between Javascript & Typescript. We are gradually porting everything over to Typescript so if you can help with that, it'd be great! +> This project is in a transition state between Javascript & Typescript. We are gradually porting everything over to Typescript, so if you can help with that, it'd be great! ### The tech stack -We try to keep the stack as lean as possible +We try to keep the stack as lean as possible: 1. React Native 2. Typescript/Javascript @@ -95,17 +95,17 @@ We try to keep the stack as lean as possible The app codebase is distributed over two primary directories. `native/` and `app/`. -- `native/`: Includes `android/` and `ios/` folders and everything related to react native core functionality like bundling, development and packaging. Any react-native dependency that has native code i.e android & ios folders, is installed here. +- `native/`: Includes `android/` and `ios/` folders and everything related to react native core functionality like bundling, development, and packaging. Any react-native dependency with native code, i.e., android & ios folders, is installed here. -- `app/`: Includes all the app code other than the native part. All JS only dependencies are installed here. - - `components/`: Each component serves a specific purpose in the app UI, for example the `Paragraph` component is used to render paragraphs in the app and a `Header` component is used to render a `header` on all screens. - - `common/`: Features that have integral role in app functionality, for example, notesnook core is initialized here. +- `app/`: Includes all the app code other than the native part. All JS-only dependencies are installed here. + - `components/`: Each component serves a specific purpose in the app UI. For example, the `Paragraph` component is used to render paragraphs in the app, and a `Header` component is used to render a `header` on all screens. + - `common/`: Features that are integral to the app's functionality. For example, the notesnook core is initialized here. - `hooks/`: Hooks for different app logic - - `navigation/`: Includes app navigation specific code. Here the app navigation, editor & side menu are rendered side by side in fluid tabs. + - `navigation/`: Includes app navigation-specific code. Here the app navigation, editor & side menu are rendered side by side in fluid tabs. - `screens`: Navigator screens. - - `services`: Parts of code that do a specific function, for example, the `sync` service is responsibe for running Sync from anywhere in the app. - - `stores`: We use `zustand` for global state management in the app. There are multiple stores that provide the state for different parts of the app. - - `utils`: General purpose stuff such as constant values, utility functions etc. + - `services`: Parts of code that do a specific function. For example, the `sync` service runs Sync from anywhere in the app. + - `stores`: We use `zustand` for global state management in the app. Multiple stores provide the state for different parts of the app. + - `utils`: General purpose stuff such as constant values, utility functions, etc. There are several other folders at the root: @@ -115,11 +115,11 @@ There are several other folders at the root: ### Running the tests -When you are done making the required changes, you will need to run the tests to make sure you didn't break anything. We use Detox as the testing framework & the tests can be started as follows: +When you are done making the required changes, you must run the tests to ensure you didn't break anything. We use Detox as the testing framework & the tests can be started as follows: ### Android -To run the tests on android, you will need to create an emulator device on your system: +To run the tests on Android, you will need to create an emulator device on your system: ``` $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_5_API_31 -d pixel --package "system-images;android-31;default;x86_64" @@ -127,13 +127,13 @@ $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_5_API_31 -d pixel --packa If you face problems, follow the detailed guide in [Detox documentation](https://wix.github.io/Detox/docs/introduction/android-dev-env). Keep the emulator name set to `Pixel_5_API_31`. -Once you have created an emulator device, build the android apks +Once you have created an emulator device, build the Android apks: ``` npm run build:android ``` -Finally run the tests +Finally, run the tests: ``` npm run test:android @@ -141,9 +141,9 @@ npm run test:android ### iOS -To run e2e tests on iOS simulator, you must be on a Mac with XCode installed. +To run e2e tests on the iOS simulator, you must be on a Mac with XCode installed. -First install [AppleSimulatorUtils](https://github.com/wix/AppleSimulatorUtils) +First, install [AppleSimulatorUtils](https://github.com/wix/AppleSimulatorUtils): ``` brew tap wix/brew @@ -156,7 +156,7 @@ Now build the iOS app for testing: npm run build:ios ``` -Finally run the tests: +Finally, run the tests: ``` npm run test:ios diff --git a/apps/web/README.md b/apps/web/README.md index c6a1b173c..15c62787b 100644 --- a/apps/web/README.md +++ b/apps/web/README.md @@ -12,7 +12,7 @@ ### The desktop app? -You can find all the desktop related code in [the `desktop/` directory](./desktop/). Since it uses the web app directly, we are keeping both together. (We should probably move it to it's own project at some point.) +You can find all the desktop-related code in [the `desktop/` directory](./desktop/). Since it uses the web app directly, we are keeping both together. (We should probably move it to its own project at some point.) ### Downloads & releases @@ -21,7 +21,7 @@ You can find all the desktop related code in [the `desktop/` directory](./deskto ## Build instructions -**Before you start it is recommended that you read [the contributing guidelines](/CONTRIBUTING.md).** +> **Before you start, it is recommended that you read [the contributing guidelines](/CONTRIBUTING.md).** ### Setting up the development environment @@ -66,11 +66,11 @@ npx serve apps/web/build ## Developer guide -> This project is in a transition state between Javascript & Typescript. We are gradually porting everything over to Typescript so if you can help with that, it'd be great! +> This project is in a transition state between Javascript & Typescript. We are gradually porting everything over to Typescript, so if you can help with that, it'd be great! ### The tech stack -We try to keep the stack as lean as possible +We try to keep the stack as lean as possible: 1. React v17: UI framework 2. Typescript/Javascript: The logical side of the app @@ -82,21 +82,21 @@ We try to keep the stack as lean as possible ### Project structure -1. `src/`: 99% of the source code lives here & this is also where you'll be spending most of your time. - 1. `index.tsx`: **the app entrypoint** responsible for loading the appropriate view based on the current route. - 2. `app.js`: **the default route** that contains the whole note taking experience (notes list, navigation, editor etc.) - 3. `views/`: Contains **all the views** including views for login, settings, notes, notebooks & topics. - 4. `components/`: All the **reusuable UI components** are here (e.g. button, editor, etc.) - 5. `stores/`: Contains the glue code & **logic for all the UI interaction**. For example, when you pin a note the `src/stores/note-store.js` is responsible for everything including refreshing the list to reflect the changes. - 6. `navigation/`: All the **routing & navigation** logic lives here. The app uses 2 kinds of routers: - 1. `routes.js`: This contains all the main routes like `/notes`, `/notebooks` with information on what to render when user goes to a particular route. - 2. `hash-routes.js`: The hash routes are used for temporary navigation like opening dialogs, opening a note. These look like `#/notes/6307bbd65d5d5d5cb86f6f74/edit`. - 7. `interfaces/`: This is where the **platform specific storage & encryption logic** lives. These interface implementations are used by the `@notesnook/core` to provide capabilities such as persistence & encryption. - 8. `hooks/`: Contains all the **general purpose React hooks** - 9. `utils/`: These are **general-purpose utilities** for performing various tasks such as downloading files, storing configuration etc. +1. `src/`: 99% of the source code lives here & this is also where you'll spend most of your time. + 1. `index.tsx`: **the app entry point** responsible for loading the appropriate view based on the current route. + 2. `app.js`: **the default route** that contains the whole note-taking experience (notes list, navigation, editor, etc.) + 3. `views/`: Contains **all the views**, including views for login, settings, notes, notebooks & topics. + 4. `components/`: All the **reusable UI components** are here (e.g., button, editor, etc.) + 5. `stores/`: Contains the glue code & **logic for all the UI interactions**. For example, when you pin a note, the `src/stores/note-store.js` is responsible for everything, including refreshing the list to reflect the changes. + 6. `navigation/`: All the **routing & navigation** logic lives here. The app uses two kinds of routers: + 1. `routes.js`: This contains all the main routes like `/notes`, `/notebooks` with information on what to render when the user goes to a particular route. + 2. `hash-routes.js`: The hash routes are used for temporary navigation, like opening dialogs or opening a note. These look like `#/notes/6307bbd65d5d5d5cb86f6f74/edit`. + 7. `interfaces/`: This is where the **platform-specific storage & encryption logic** lives. These interface implementations are used by the `@notesnook/core` to provide capabilities such as persistence & encryption. + 8. `hooks/`: Contains all the **general-purpose React hooks** + 9. `utils/`: These are **general-purpose utilities** for performing various tasks such as downloading files, storing configuration, etc. 10. `common/`: This directory contains **the shared logic between the whole app**. For example, this is where the database is instantiated for use throughout the app. - 11. `commands/`: These are **commands used by the desktop app** for things like checking for updates, storing backups etc. -2. `desktop/`: The Electron layer for **the desktop app lives here**. (This should be moved outside into it's own project). + 11. `commands/`: These are **commands the desktop app uses** for things like checking for updates, storing backups etc. +2. `desktop/`: The Electron layer for **the desktop app lives here**. (This should be moved outside into its own project). ### Running the tests From 2197f1ec5e7752c1314c74293155c9a90b440446 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Sat, 15 Apr 2023 16:31:59 +0500 Subject: [PATCH 05/13] mobile: fix tag suggestions in share widget (#2354) --- apps/mobile/share/search.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/mobile/share/search.js b/apps/mobile/share/search.js index c8c535d91..590dc92b8 100644 --- a/apps/mobile/share/search.js +++ b/apps/mobile/share/search.js @@ -17,23 +17,22 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import { FlashList } from "@shopify/flash-list"; import React, { useEffect, useRef, useState } from "react"; import { - ActivityIndicator, Platform, StatusBar, Text, TextInput, TouchableOpacity, - useWindowDimensions, - View + View, + useWindowDimensions } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { db } from "../app/common/database"; import { getElevation } from "../app/utils"; import { useShareStore } from "./store"; -import { FlashList } from "@shopify/flash-list"; const ListItem = ({ item, mode, close }) => { const colors = useShareStore((state) => state.colors); @@ -338,7 +337,13 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => { renderItem={renderItem} estimatedItemSize={50} ListHeaderComponent={ - searchResults.length === 0 && searchKeyword.current ? ( + mode === "selectTags" && + (searchResults.length === 0 || + (searchKeyword.current && + searchKeyword.current.length > 0 && + !searchResults.find( + (item) => item.title === searchKeyword.current + ))) ? ( Date: Sat, 15 Apr 2023 16:35:03 +0500 Subject: [PATCH 06/13] web: migrate use-media-query.js to Typescript (#2326) Signed-off-by: Abdulrehman-Jafer --- apps/web/src/hooks/{use-media-query.js => use-media-query.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename apps/web/src/hooks/{use-media-query.js => use-media-query.ts} (97%) diff --git a/apps/web/src/hooks/use-media-query.js b/apps/web/src/hooks/use-media-query.ts similarity index 97% rename from apps/web/src/hooks/use-media-query.js rename to apps/web/src/hooks/use-media-query.ts index 27ed19660..e3ba08637 100644 --- a/apps/web/src/hooks/use-media-query.js +++ b/apps/web/src/hooks/use-media-query.ts @@ -32,7 +32,7 @@ const errorMessage = * Returns the validity state of the given media query. * */ -const useMediaQuery = (mediaQuery) => { +const useMediaQuery = (mediaQuery: string) => { if (!window.matchMedia) { // eslint-disable-next-line no-console console.warn(errorMessage); From 6f5a44cd117f45b7b7065921f21c82bb691b6817 Mon Sep 17 00:00:00 2001 From: Muhammad Ali Date: Sat, 15 Apr 2023 16:37:32 +0500 Subject: [PATCH 07/13] web: do not show success toast if notebook failed to create (#2307) Co-authored-by: Abdullah Atta --- apps/web/src/common/dialog-controller.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/src/common/dialog-controller.tsx b/apps/web/src/common/dialog-controller.tsx index ea2909958..c2e8177b7 100644 --- a/apps/web/src/common/dialog-controller.tsx +++ b/apps/web/src/common/dialog-controller.tsx @@ -94,7 +94,9 @@ export function showAddNotebookDialog() { isOpen={true} onDone={async (nb: Record) => { // add the notebook to db - await db.notebooks?.add({ ...nb }); + const notebook = await db.notebooks?.add({ ...nb }); + if (!notebook) return perform(false); + notebookStore.refresh(); showToast("success", "Notebook added successfully!"); From 0b9025af11169b91dcbb464df5e88e5e0beb1054 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Sat, 15 Apr 2023 16:40:36 +0500 Subject: [PATCH 08/13] mobile: redesign reminder/notebook sheets (#2321) --- .../components/sheets/add-notebook/index.js | 113 +++++++++--------- .../app/components/sheets/reminder/index.tsx | 57 +++++---- 2 files changed, 94 insertions(+), 76 deletions(-) diff --git a/apps/mobile/app/components/sheets/add-notebook/index.js b/apps/mobile/app/components/sheets/add-notebook/index.js index 596b360aa..898ae5e75 100644 --- a/apps/mobile/app/components/sheets/add-notebook/index.js +++ b/apps/mobile/app/components/sheets/add-notebook/index.js @@ -25,22 +25,22 @@ import { TouchableOpacity, View } from "react-native"; +import { FlatList } from "react-native-actions-sheet"; import { notesnook } from "../../../../e2e/test.ids"; import { db } from "../../../common/database"; import { DDS } from "../../../services/device-detection"; -import { presentSheet, ToastEvent } from "../../../services/event-manager"; +import { ToastEvent, presentSheet } from "../../../services/event-manager"; import Navigation from "../../../services/navigation"; import { useMenuStore } from "../../../stores/use-menu-store"; import { useRelationStore } from "../../../stores/use-relation-store"; -import { ph, pv, SIZE } from "../../../utils/size"; +import { SIZE, ph, pv } from "../../../utils/size"; import { sleep } from "../../../utils/time"; -import DialogHeader from "../../dialog/dialog-header"; import { Button } from "../../ui/button"; import { IconButton } from "../../ui/icon-button"; import Input from "../../ui/input"; import Seperator from "../../ui/seperator"; +import Heading from "../../ui/typography/heading"; import { MoveNotes } from "../move-notes/movenote"; -import { FlatList } from "react-native-actions-sheet"; let refs = []; export class AddNotebookSheet extends React.Component { @@ -245,13 +245,34 @@ export class AddNotebookSheet extends React.Component { willFocus && this.topicInputRef.current?.focus(); }; + renderTopicItem = ({ item, index }) => ( + { + this.prevIndex = index; + this.prevItem = item; + this.topicInputRef.current?.setNativeProps({ + text: item + }); + this.topicInputRef.current?.focus(); + this.currentInputValue = item; + this.setState({ + editTopic: true + }); + }} + onDelete={this.onDelete} + index={index} + colors={this.props.colors} + /> + ); + render() { const { colors } = this.props; const { topics, topicInputFocused, notebook } = this.state; return ( - - + + + + {notebook && notebook.dateCreated + ? "Edit Notebook" + : "New Notebook"} + +