Compare commits

..

2 Commits

Author SHA1 Message Date
ammarahm-ed
da36e69345 mobile: add background fetch ios 2023-01-17 15:46:23 +05:00
ammarahm-ed
66bd6b23b5 mobile: add background sync 2023-01-17 15:12:23 +05:00
304 changed files with 37462 additions and 35357 deletions

View File

@@ -1,64 +0,0 @@
name: Publish @notesnook/android-internal
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@master
with:
node-version: '16'
cache: 'npm'
cache-dependency-path: |
apps/mobile/package-lock.json
apps/web/package-lock.json
packages/core/package-lock.json
packages/crypto/package-lock.json
packages/crypto-worker/package-lock.json
packages/editor-mobile/package-lock.json
packages/editor/package-lock.json
packages/logger/package-lock.json
packages/streamable-fs/package-lock.json
packages/theme/package-lock.json
- name: Use specific Java version for the builds
uses: joschi/setup-jdk@v2
with:
java-version: '11'
architecture: 'x64'
- name: Install node modules
run: |
npm ci
- name: Make Gradlew Executable
run: cd apps/mobile/native/android && chmod +x ./gradlew
- name: Build unsigned app bundle
run: yarn release:android:bundle
- name: Sign app bundle for Playstore release
id: sign_app
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: apps/mobile/native/android/app/build/outputs/bundle/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Publish to Playstore
id: deploy
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: com.streetwriters.notesnook
releaseFile: ${{steps.sign_app.outputs.signedReleaseFile}}
track: internal
status: completed
whatsNewDirectory: apps/mobile/native/android/releasenotes/

View File

@@ -95,7 +95,7 @@ jobs:
- name: Publish to Playstore
id: deploy
uses: r0adkll/upload-google-play@v1.1.1
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: com.streetwriters.notesnook

View File

@@ -127,9 +127,7 @@ jobs:
path: ./apps/web/desktop/build
- name: Install packages
run: |
npm i
npm i dmg-license
run: npm i
working-directory: ./apps/web/desktop
- name: Install provisioning profile

View File

@@ -1,11 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-playwright.playwright",
"firefox-devtools.vscode-firefox-debug",
"msjsdiag.vscode-react-native"
]
}

View File

@@ -1,72 +0,0 @@
{
"folders": [
{
"name": "✨ notesnook",
"path": ".."
},
{
"name": "🚀 @notesnook/mobile",
"path": "../apps/mobile"
},
{
"name": "🚀 @notesnook/web",
"path": "../apps/web"
},
{
"name": "🚀 @notesnook/desktop",
"path": "../apps/web/desktop"
},
{
"name": "🚀 @notesnook/web-clipper",
"path": "../extensions/web-clipper"
},
{
"name": "📦 @notesnook/clipper",
"path": "../packages/clipper"
},
{
"name": "📦 @notesnook/core",
"path": "../packages/core"
},
{
"name": "📦 @notesnook/crypto",
"path": "../packages/crypto"
},
{
"name": "📦 @notesnook/crypto-worker",
"path": "../packages/crypto-worker"
},
{
"name": "📦 @notesnook/editor",
"path": "../packages/editor"
},
{
"name": "📦 @notesnook/editor-mobile",
"path": "../packages/editor-mobile"
},
{
"name": "📦 @notesnook/logger",
"path": "../packages/logger"
},
{
"name": "📦 @notesnook/streamable-fs",
"path": "../packages/streamable-fs"
},
{
"name": "📦 @notesnook/theme",
"path": "../packages/theme"
}
],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib",
"javascript.format.enable": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
"eslint.packageManager": "npm",
"eslint.run": "onSave",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.execArgv": ["--cache"]
}
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}

View File

@@ -28,6 +28,12 @@ If you've thought of a way that Notesnook could be better, we want to hear about
Before you open a new feature request, please make sure it's not a duplicate. **Duplicate feature requests & bug reports are closed immediately.**
### Improving documentation
All app related documentation can be found in the `docs/` directory. All the files in this directory are simple markdown files which you can edit either directly on GitHub, or in your favorite text editor.
If you find a mistake in the documentation or would like to contribute something new to the documentation, feel free to open a pull request; creating an issue for this is not required.
### Helping out in the issue tracker
There are always new issues getting opened that need to be triaged, sorted & organized, so the developers can easily find the most critical and/or relevant bugs to fix. Any help in this regard is appreciated.
@@ -85,11 +91,7 @@ The DCO is a declaration attached to every contribution made by every developer
Signed-off-by: Jane Smith <jane.smith@email.com>
```
On VSCode, it looks like this:
![](resources/vscode-signed-off-commit.png)
You may type this line on your own when writing your commit messages. However, if your [user.name](http://user.name) and [user.email](http://user.email) are set in your git configs, you can use `-s` or `--signoff` to add the `Signed-off-by` line to the end of the commit message automatically.
You may type this line on your own when writing your commit messages. However, if your [user.name](http://user.name) and [user.email](http://user.email) are set in your git configs, you can use `-s` or `--signoff` to add the `Signed-off-by` line to the end of the commit message.
#### Include `<scope>:` in your commit message

View File

@@ -25,4 +25,4 @@
"request": "attach"
}
]
}
}

1
apps/mobile/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1 @@
{}

View File

@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import "react-native-gesture-handler";
import React, { useEffect } from "react";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { SafeAreaProvider } from "react-native-safe-area-context";
@@ -32,6 +32,7 @@ import { useUserStore } from "./stores/use-user-store";
import { View } from "react-native";
import { useState } from "react";
import NetInfo from "@react-native-community/netinfo";
NetInfo.configure({
reachabilityUrl: "https://notesnook.com",
reachabilityTest: (response) => {
@@ -50,7 +51,6 @@ const App = () => {
if (appLockMode && appLockMode !== "none") {
useUserStore.getState().setVerifyUser(true);
}
//BackgroundSync.start();
setInit(true);
setTimeout(async () => {
SettingsService.onFirstLaunch();

View File

@@ -26,6 +26,7 @@ import { eSendEvent } from "../../services/event-manager";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import BaseDialog from "../dialog/base-dialog";
import SheetProvider from "../sheet-provider";
import { Progress } from "../sheets/progress";
import { Button } from "../ui/button";
@@ -82,6 +83,9 @@ export const Login = ({ changeMode }) => {
<>
<ForgotPassword />
<SheetProvider context="two_factor_verify" />
{loading ? (
<BaseDialog transparent={true} visible={true} animation="fade" />
) : null}
<Animated.View
entering={FadeInDown}
exiting={FadeOutUp}
@@ -130,7 +134,6 @@ export const Login = ({ changeMode }) => {
marginTop: 5
}}
onPress={() => {
if (loading) return;
changeMode(1);
}}
size={SIZE.md}
@@ -169,7 +172,7 @@ export const Login = ({ changeMode }) => {
errorMessage="Email is invalid"
placeholder="Enter your email"
defaultValue={email.current}
editable={step === LoginSteps.emailAuth && !loading}
editable={step === LoginSteps.emailAuth}
onSubmit={() => {
passwordInputRef.current?.focus();
}}
@@ -191,7 +194,6 @@ export const Login = ({ changeMode }) => {
autoCorrect={false}
placeholder="Password"
marginBottom={0}
editable={!loading}
defaultValue={password.current}
onSubmit={() => login()}
/>
@@ -203,7 +205,6 @@ export const Login = ({ changeMode }) => {
paddingHorizontal: 0
}}
onPress={() => {
if (loading) return;
SheetManager.show("forgotpassword_sheet", email.current);
}}
textStyle={{
@@ -227,10 +228,7 @@ export const Login = ({ changeMode }) => {
borderRadius: 100
}}
loading={loading}
onPress={() => {
if (loading) return;
login();
}}
onPress={login}
type="accent"
title={
loading
@@ -250,7 +248,6 @@ export const Login = ({ changeMode }) => {
marginTop: 10
}}
onPress={() => {
if (loading) return;
setStep(LoginSteps.emailAuth);
setLoading(false);
}}

View File

@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React, { useRef, useState } from "react";
import { Dimensions, View } from "react-native";
import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated";
import umami from "../../common/analytics";
import { db } from "../../common/database";
import { DDS } from "../../services/device-detection";
import { ToastEvent } from "../../services/event-manager";
@@ -30,6 +31,7 @@ import { useUserStore } from "../../stores/use-user-store";
import { openLinkInBrowser } from "../../utils/functions";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import BaseDialog from "../dialog/base-dialog";
import { Button } from "../ui/button";
import Input from "../ui/input";
import { SvgView } from "../ui/svg";
@@ -77,6 +79,7 @@ export const Signup = ({ changeMode, trial }) => {
clearMessage();
setEmailVerifyMessage();
hideAuth();
umami.pageView("/account-created", "/welcome/signup");
await sleep(300);
if (trial) {
PremiumService.sheet(null, null, true);
@@ -96,6 +99,9 @@ export const Signup = ({ changeMode, trial }) => {
return (
<>
{loading ? (
<BaseDialog transparent={true} visible={true} animation="fade" />
) : null}
<Animated.View
entering={FadeInDown}
exiting={FadeOutUp}
@@ -144,7 +150,6 @@ export const Signup = ({ changeMode, trial }) => {
textAlign: "center"
}}
onPress={() => {
if (loading) return;
changeMode(0);
}}
size={SIZE.md}
@@ -232,10 +237,7 @@ export const Signup = ({ changeMode, trial }) => {
borderRadius: 100
}}
loading={loading}
onPress={() => {
if (loading) return;
signup();
}}
onPress={signup}
type="accent"
title={loading ? null : "Agree and continue"}
/>

View File

@@ -54,7 +54,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
app: "Enter the 6 digit code from your authenticator app to continue logging in",
sms: "Enter the 6 digit code sent to your phone number to continue logging in",
email: "Enter the 6 digit code sent to your email to continue logging in",
recoveryCode: "Enter the recovery code to continue logging in"
recoveryCode: "Enter the 8 digit recovery code to continue logging in"
};
const secondaryMethodsText = {
@@ -65,7 +65,9 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
};
const onNext = async () => {
if (!code.current || code.current.length < 6) return;
const length = currentMethod.method === "recoveryCode" ? 8 : 6;
if (!code.current || code.current.length !== length) return;
setLoading(true);
inputRef.current?.blur();
await onMfaLogin(
@@ -200,26 +202,22 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
<>
<Input
placeholder={
currentMethod.method === "recoveryCode"
? "xxxxx-xxxxx"
: "xxxxxx"
currentMethod.method === "recoveryCode" ? "xxxxxxxx" : "xxxxxx"
}
testID={"input.totp"}
maxLength={
currentMethod.method === "recoveryCode" ? undefined : 6
}
maxLength={currentMethod.method === "recoveryCode" ? 8 : 6}
fwdRef={inputRef}
textAlign="center"
onChangeText={(value) => {
code.current = value;
//onNext();
onNext();
}}
inputStyle={{
fontSize: SIZE.lg,
height: 60,
textAlign: "center",
letterSpacing: 10,
width: 250
width: null
}}
keyboardType={
currentMethod.method === "recoveryCode" ? "default" : "numeric"
@@ -302,9 +300,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
TwoFactorVerification.present = (onMfaLogin, data, context) => {
presentSheet({
component: () => (
<TwoFactorVerification onMfaLogin={onMfaLogin} mfaInfo={data} />
),
component: <TwoFactorVerification onMfaLogin={onMfaLogin} mfaInfo={data} />,
context: context || "two_factor_verify",
onClose: () => {
onMfaLogin();

View File

@@ -75,7 +75,6 @@ export const useLogin = (onFinishLogin) => {
mfa.code,
mfa.method
);
if (success) {
setStep(LoginSteps.passwordAuth);
setLoading(false);
@@ -94,8 +93,6 @@ export const useLogin = (onFinishLogin) => {
}
}
}, mfaInfo);
} else {
finishWithError(new Error("Unable to send 2FA code"));
}
break;
}

View File

@@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import { KeyboardAvoidingView, Platform, View } from "react-native";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { KeyboardAvoidingView, Platform, SafeAreaView } from "react-native";
import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
import { useSettingStore } from "../../stores/use-setting-store";
import { Header } from "../header";
@@ -29,7 +28,6 @@ export const Container = ({ children }) => {
const introCompleted = useSettingStore(
(state) => state.settings.introCompleted
);
const insets = useGlobalSafeAreaInsets();
return (
<KeyboardAvoidingView
behavior="padding"
@@ -38,12 +36,10 @@ export const Container = ({ children }) => {
flex: 1
}}
>
<View
<SafeAreaView
style={{
flex: 1,
overflow: "hidden",
paddingTop: Platform.OS === "android" ? 0 : insets.top,
paddingBottom: Platform.OS === "android" ? 0 : insets.bottom
overflow: "hidden"
}}
>
{!introCompleted ? null : (
@@ -54,7 +50,7 @@ export const Container = ({ children }) => {
)}
{children}
</View>
</SafeAreaView>
</KeyboardAvoidingView>
);
};

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import { Text, View, ViewStyle } from "react-native";
import { Text, View } from "react-native";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
@@ -41,7 +41,6 @@ type DialogHeaderProps = {
padding?: number;
centered?: boolean;
titlePart?: string;
style?: ViewStyle;
};
const DialogHeader = ({
@@ -51,8 +50,7 @@ const DialogHeader = ({
paragraphColor,
padding,
centered,
titlePart,
style
titlePart
}: DialogHeaderProps) => {
const colors = useThemeStore((state) => state.colors);
@@ -64,8 +62,7 @@ const DialogHeader = ({
alignItems: "center",
justifyContent: "space-between",
minHeight: 50,
paddingHorizontal: padding,
...style
paddingHorizontal: padding
}}
>
<View

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import React, { useEffect } from "react";
import {
Dimensions,
Image,
@@ -26,6 +26,7 @@ import {
View
} from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import umami from "../../common/analytics";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { useNavigationFocus } from "../../hooks/use-navigation-focus";
import { DDS } from "../../services/device-detection";
@@ -49,6 +50,9 @@ export const SVG_Z =
const Intro = ({ navigation }) => {
const colors = useThemeStore((state) => state.colors);
const introCompleted = useSettingStore(
(state) => state.settings.introCompleted
);
const isTelemetryEnabled = useSettingStore(
(state) => state.settings.telemetry
);
@@ -60,6 +64,12 @@ const Intro = ({ navigation }) => {
}
});
useEffect(() => {
if (!introCompleted) {
umami.pageView("/welcome", "", []);
}
}, [introCompleted]);
return (
<View
testID="notesnook.splashscreen"
@@ -161,6 +171,8 @@ const Intro = ({ navigation }) => {
navigation.navigate("AppLock", {
welcome: true
});
umami.pageView("/home", "/welcome");
}}
style={{
paddingHorizontal: 24,

File diff suppressed because one or more lines are too long

View File

@@ -56,6 +56,7 @@ const ReminderItem = React.memo(
>
<View
style={{
flexWrap: "wrap",
flexShrink: 1,
opacity: item.disabled ? 0.5 : 1
}}
@@ -93,13 +94,13 @@ const ReminderItem = React.memo(
backgroundColor: colors.nav,
borderRadius: 5,
flexDirection: "row",
paddingHorizontal: 6,
paddingHorizontal: 5,
paddingVertical: 3,
alignItems: "center",
marginTop: 5,
justifyContent: "flex-start",
alignSelf: "flex-start",
marginRight: 10,
height: 30
marginRight: 10
}}
>
<Icon
@@ -122,13 +123,13 @@ const ReminderItem = React.memo(
backgroundColor: colors.nav,
borderRadius: 5,
flexDirection: "row",
paddingHorizontal: 6,
paddingHorizontal: 5,
paddingVertical: 3,
alignItems: "center",
marginTop: 5,
justifyContent: "flex-start",
alignSelf: "flex-start",
marginRight: 10,
height: 30
marginRight: 10
}}
>
<Icon name="reload" size={SIZE.md} color={colors.accent} />

View File

@@ -0,0 +1,326 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Clipboard from "@react-native-clipboard/clipboard";
import React, { useEffect, useState } from "react";
import { View } from "react-native";
import Animated, { SlideInUp, SlideOutDown } from "react-native-reanimated";
import { db } from "../../../common/database";
import { openVault, ToastEvent } from "../../../services/event-manager";
import Navigation from "../../../services/navigation";
import { useMenuStore } from "../../../stores/use-menu-store";
import { useNotebookStore } from "../../../stores/use-notebook-store";
import { useRelationStore } from "../../../stores/use-relation-store";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { useTrashStore } from "../../../stores/use-trash-store";
import { dWidth, getElevation, toTXT } from "../../../utils";
import { deleteItems } from "../../../utils/functions";
import { presentDialog } from "../../dialog/functions";
import { Button } from "../../ui/button";
import { IconButton } from "../../ui/icon-button";
export const ActionStrip = ({ note, setActionStrip }) => {
const colors = useThemeStore((state) => state.colors);
const selectionMode = useSelectionStore((state) => state.selectionMode);
const setNotebooks = useNotebookStore((state) => state.setNotebooks);
const setMenuPins = useMenuStore((state) => state.setMenuPins);
const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
const setSelectionMode = useSelectionStore((state) => state.setSelectionMode);
const [isPinnedToMenu, setIsPinnedToMenu] = useState(false);
const [width, setWidth] = useState(dWidth - 16);
useEffect(() => {
if (note.type === "note") return;
setIsPinnedToMenu(db.shortcuts.exists(note.id));
}, [note.id, note.type]);
const updateNotes = () => {
Navigation.queueRoutesForUpdate(
"Notes",
"Favorites",
"ColoredNotes",
"TaggedNotes",
"TopicNotes"
);
};
const actions = [
{
title: "Pin " + note.type,
icon: note.pinned ? "pin-off" : "pin",
visible: note.type === "note" || note.type === "notebook",
onPress: async () => {
if (!note.id) return;
if (note.type === "note") {
await db.notes.note(note.id).pin();
} else {
await db.notebooks.notebook(note.id).pin();
setNotebooks();
}
updateNotes();
setActionStrip(false);
}
},
{
title: "Add to favorites",
icon: note.favorite ? "star-off" : "star",
onPress: async () => {
if (!note.id) return;
if (note.type === "note") {
await db.notes.note(note.id).favorite();
} else {
await db.notebooks.notebook(note.id).favorite();
}
updateNotes();
setActionStrip(false);
},
visible: note.type === "note",
color: !note.favorite ? "orange" : null
},
{
title: isPinnedToMenu
? "Remove Shortcut from Menu"
: "Add Shortcut to Menu",
icon: isPinnedToMenu ? "link-variant-remove" : "link-variant",
onPress: async () => {
try {
if (isPinnedToMenu) {
await db.shortcuts.remove(note.id);
ToastEvent.show({
heading: "Shortcut removed from menu",
type: "success"
});
} else {
if (note.type === "topic") {
await db.shortcuts.add({
item: {
type: "topic",
id: note.id,
notebookId: note.notebookId
}
});
} else {
await db.shortcuts.add({
item: {
type: "notebook",
id: note.id
}
});
}
ToastEvent.show({
heading: "Shortcut added to menu",
type: "success"
});
}
setIsPinnedToMenu(db.shortcuts.exists(note.id));
setMenuPins();
setActionStrip(false);
} catch (e) {
console.error(e);
}
},
visible: note.type !== "note" && note.type !== "reminder"
},
{
title: "Copy Note",
icon: "content-copy",
visible: note.type === "note",
onPress: async () => {
if (note.locked) {
openVault({
copyNote: true,
novault: true,
locked: true,
item: note,
title: "Copy note",
description: "Unlock note to copy to clipboard."
});
} else {
let text = await toTXT(note);
text = `${note.title}\n \n ${text}`;
Clipboard.setString(text);
ToastEvent.show({
heading: "Note copied to clipboard",
type: "success"
});
}
setActionStrip(false);
}
},
{
title: "Restore " + note.itemType,
icon: "delete-restore",
onPress: async () => {
await db.trash.restore(note.id);
Navigation.queueRoutesForUpdate(
"Notes",
"Favorites",
"ColoredNotes",
"TaggedNotes",
"TopicNotes",
"Trash",
"Notebooks"
);
ToastEvent.show({
heading:
note.type === "note"
? "Note restored from trash"
: "Notebook restored from trash",
type: "success"
});
setActionStrip(false);
},
visible: note.type === "trash"
},
{
title: "Delete" + note.itemType,
icon: "delete",
visible: note.type === "trash",
onPress: () => {
presentDialog({
title: "Permanent delete",
paragraph: `Are you sure you want to delete this ${note.itemType} permanantly from trash?`,
positiveText: "Delete",
negativeText: "Cancel",
positivePress: async () => {
await db.trash.delete(note.id);
useTrashStore.getState().setTrash();
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
heading: "Permanantly deleted items",
type: "success",
context: "local"
});
},
positiveType: "errorShade"
});
setActionStrip(false);
}
},
{
title: "Delete" + note.type,
icon: "delete",
visible: note.type !== "trash",
onPress: async () => {
if (note.type === "reminder") {
presentDialog({
title: `Delete ${note.type}`,
paragraph: "This reminder will be removed",
positivePress: async () => {
const routes = [];
await db.reminders.remove(note.id);
routes.push("Reminders");
Navigation.queueRoutesForUpdate(...routes);
useRelationStore.getState().update();
},
positiveText: "Delete",
positiveType: "errorShade"
});
return;
}
try {
await deleteItems(note);
} catch (e) {
console.error(e);
}
setActionStrip(false);
}
},
{
title: "Close",
icon: "close",
onPress: () => setActionStrip(false),
color: colors.light,
bg: colors.red,
visible: true
}
];
return (
<Animated.View
onLayout={(event) => {
setWidth(event.nativeEvent.layout.width);
}}
entering={SlideInUp.springify().mass(0.4)}
exiting={SlideOutDown}
style={{
position: "absolute",
zIndex: 999,
width: "102%",
height: "100%",
flexDirection: "row",
justifyContent: "flex-end",
alignItems: "center"
}}
>
<Button
type="accent"
title="Select"
icon="check"
tooltipText="Select Item"
onPress={() => {
if (!selectionMode) {
setSelectionMode(true);
}
setSelectedItem(note);
setActionStrip(false);
}}
style={{
borderRadius: 100,
paddingHorizontal: 12,
...getElevation(5)
}}
height={30}
/>
{actions.map((item) =>
item.visible ? (
<View
key={item.icon}
style={{
width: width / 1.4 / actions.length,
height: width / 1.4 / actions.length,
backgroundColor: item.bg || colors.nav,
borderRadius: 100,
justifyContent: "center",
alignItems: "center",
...getElevation(5),
marginLeft: 15
}}
>
<IconButton
color={item.color || colors.heading}
onPress={item.onPress}
tooltipText={item.title}
top={60}
bottom={60}
name={item.icon}
size={width / 2.8 / actions.length}
/>
</View>
) : null
)}
</Animated.View>
);
};

View File

@@ -17,13 +17,19 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useRef } from "react";
import { useSelectionStore } from "../../../stores/use-selection-store";
import React, { useEffect, useState } from "react";
import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../../services/event-manager";
import { useSettingStore } from "../../../stores/use-setting-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { history } from "../../../utils";
import { PressableButton } from "../../ui/pressable";
import { ActionStrip } from "./action-strip";
import { Filler } from "./back-fill";
import { SelectionIcon } from "./selection";
import { useRef } from "react";
const SelectionWrapper = ({
children,
@@ -36,6 +42,7 @@ const SelectionWrapper = ({
}) => {
const itemId = useRef(item.id);
const colors = useThemeStore((state) => state.colors);
const [actionStrip, setActionStrip] = useState(false);
const notebooksListMode = useSettingStore(
(state) => state.settings.notebooksListMode
);
@@ -49,18 +56,35 @@ const SelectionWrapper = ({
if (item.id !== itemId.current) {
itemId.current = item.id;
if (actionStrip) {
setActionStrip(false);
}
}
const _onLongPress = () => {
if (!useSelectionStore.getState().selectionMode) {
useSelectionStore.getState().setSelectionMode(true);
}
useSelectionStore.getState().setSelectedItem(item);
if (history.selectedItemsList.length > 0) return;
setActionStrip(!actionStrip);
};
const _onPress = async () => {
if (actionStrip) {
setActionStrip(false);
return;
}
await onPress();
};
const closeStrip = () => {
setActionStrip(false);
};
useEffect(() => {
eSubscribeEvent("navigate", closeStrip);
return () => {
eUnSubscribeEvent("navigate", closeStrip);
};
}, []);
return (
<PressableButton
customColor={isSheet ? colors.transGray : "transparent"}
@@ -87,10 +111,15 @@ const SelectionWrapper = ({
) : null}
<SelectionIcon
compactMode={compactMode}
setActionStrip={setActionStrip}
item={item}
onLongPress={onLongPress}
/>
{children}
{actionStrip ? (
<ActionStrip note={item} setActionStrip={setActionStrip} />
) : null}
</PressableButton>
);
};

View File

@@ -24,7 +24,7 @@ import { useSelectionStore } from "../../../stores/use-selection-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
export const SelectionIcon = ({ item }) => {
export const SelectionIcon = ({ setActionStrip, item }) => {
const colors = useThemeStore((state) => state.colors);
const selectionMode = useSelectionStore((state) => state.selectionMode);
@@ -35,6 +35,7 @@ export const SelectionIcon = ({ item }) => {
useEffect(() => {
if (selectionMode) {
setActionStrip(false);
let exists = selectedItemsList.filter(
(o) => o.dateCreated === item.dateCreated
);
@@ -49,9 +50,16 @@ export const SelectionIcon = ({ item }) => {
}
}
}
}, [selectedItemsList, item.id, selectionMode, item.dateCreated, selected]);
}, [
selectedItemsList,
item.id,
selectionMode,
setActionStrip,
item.dateCreated,
selected
]);
return selectionMode ? (
return selectionMode && selected ? (
<View
style={{
width: 40,
@@ -65,13 +73,11 @@ export const SelectionIcon = ({ item }) => {
}}
pointerEvents="none"
>
{selected ? (
<Icon
size={SIZE.xl}
color={selected ? colors.accent : colors.icon}
name={"check"}
/>
) : null}
<Icon
size={SIZE.xl}
color={selected ? colors.accent : colors.icon}
name="check"
/>
</View>
) : null;
};

View File

@@ -53,52 +53,45 @@ export const Card = ({ color, warning }) => {
>
<View
style={{
flexDirection: "row",
alignItems: "center"
width: 40,
backgroundColor:
messageBoardState.type === "error"
? hexToRGBA(colors.red, 0.15)
: hexToRGBA(color, 0.15),
height: 40,
borderRadius: 100,
alignItems: "center",
justifyContent: "center"
}}
>
<View
style={{
width: 40,
backgroundColor:
messageBoardState.type === "error"
? hexToRGBA(colors.red, 0.15)
: hexToRGBA(color, 0.15),
height: 40,
borderRadius: 100,
alignItems: "center",
justifyContent: "center"
}}
>
<Icon
size={SIZE.lg}
color={
messageBoardState.type === "error" ? colors.errorText : color
}
name={messageBoardState.icon}
/>
</View>
<Icon
size={SIZE.lg}
color={
messageBoardState.type === "error" ? colors.errorText : color
}
name={messageBoardState.icon}
/>
</View>
<View
<View
style={{
marginLeft: 10,
flexShrink: 1,
marginRight: 10
}}
>
<Paragraph color={colors.icon} size={SIZE.xs}>
{messageBoardState.message}
</Paragraph>
<Paragraph
style={{
marginLeft: 10,
flexShrink: 1,
marginRight: 10
flexWrap: "wrap",
flexShrink: 1
}}
color={colors.heading}
>
<Paragraph color={colors.icon} size={SIZE.xs}>
{messageBoardState.message}
</Paragraph>
<Paragraph
style={{
flexWrap: "wrap",
flexShrink: 1
}}
color={colors.heading}
>
{messageBoardState.actionText}
</Paragraph>
</View>
{messageBoardState.actionText}
</Paragraph>
</View>
<View

View File

@@ -18,8 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useState } from "react";
import { ActivityIndicator, Platform, ScrollView, View } from "react-native";
import { ActivityIndicator, ScrollView, View } from "react-native";
import { LAUNCH_ROCKET } from "../../assets/images/assets";
import umami from "../../common/analytics";
import { db } from "../../common/database";
import { usePricing } from "../../hooks/use-pricing";
import { DDS } from "../../services/device-detection";
@@ -47,6 +48,7 @@ import { Walkthrough } from "../walkthroughs";
import { features } from "./features";
import { Group } from "./group";
import { PricingPlans } from "./pricing-plans";
import { Platform } from "react-native";
export const Component = ({ close, promo }) => {
const colors = useThemeStore((state) => state.colors);
@@ -58,6 +60,7 @@ export const Component = ({ close, promo }) => {
const onPress = async () => {
if (user) {
umami.pageView("/pro-plans", "/pro-screen");
presentSheet({
context: "pricing_plans",
component: (
@@ -66,6 +69,7 @@ export const Component = ({ close, promo }) => {
});
} else {
close();
umami.pageView("/signup", "/pro-screen");
setTimeout(() => {
eSendEvent(eOpenLoginDialog, AuthMode.trialSignup);
}, 400);

View File

@@ -17,9 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useCallback, useEffect, useState } from "react";
import React, { useEffect, useState } from "react";
import { ActivityIndicator, Platform, Text, View } from "react-native";
import * as RNIap from "react-native-iap";
import umami from "../../common/analytics";
import { db } from "../../common/database";
import { usePricing } from "../../hooks/use-pricing";
import {
@@ -47,6 +48,7 @@ import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { Walkthrough } from "../walkthroughs";
import { PricingItem } from "./pricing-item";
import { useCallback } from "react";
const promoCyclesMonthly = {
1: "first month",
@@ -139,6 +141,10 @@ export const PricingPlans = ({
setBuying(false);
return;
}
umami.pageView(
"/iap-native",
`${compact ? "pro-sheet" : "pro-screen"}/pro-plans`
);
await RNIap.requestSubscription(
product?.productId,
false,

View File

@@ -22,10 +22,12 @@ import { View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { notesnook } from "../../../e2e/test.ids";
import { db } from "../../common/database";
import { DDS } from "../../services/device-detection";
import { eSendEvent } from "../../services/event-manager";
import Navigation from "../../services/navigation";
import { useMenuStore } from "../../stores/use-menu-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { dWidth } from "../../utils";
import { COLORS_NOTE } from "../../utils/color-scheme";
import { refreshNotesPage } from "../../utils/events";
import { SIZE } from "../../utils/size";
@@ -33,7 +35,9 @@ import { PressableButton } from "../ui/pressable";
export const ColorTags = ({ item }) => {
const [note, setNote] = useState(item);
const setColorNotes = useMenuStore((state) => state.setColorNotes);
const isTablet = useSettingStore((state) => state.deviceMode) !== "mobile";
const dimensions = useSettingStore((state) => state.dimensions);
let width = dimensions.width > 600 ? 600 : 500;
const changeColor = async (color) => {
if (note.color === color.name) {
await db.notes.note(note.id).uncolor();
@@ -67,12 +71,11 @@ export const ColorTags = ({ item }) => {
key={color.value}
onPress={() => changeColor(color)}
customStyle={{
width: 30,
height: 30,
width: DDS.isTab ? width / 10 : dWidth / 9,
height: DDS.isTab ? width / 10 : dWidth / 9,
borderRadius: 100,
justifyContent: "center",
alignItems: "center",
marginRight: isTablet ? 10 : undefined
alignItems: "center"
}}
>
{note.color?.toLowerCase() === color.name ? (
@@ -87,10 +90,12 @@ export const ColorTags = ({ item }) => {
style={{
flexDirection: "row",
flexWrap: "wrap",
flexGrow: isTablet ? undefined : 1,
paddingHorizontal: 12,
width: "100%",
marginVertical: 10,
marginTop: 20,
alignItems: "center",
justifyContent: isTablet ? "center" : "space-between"
justifyContent: "space-between"
}}
>
{Object.keys(COLORS_NOTE).map(_renderColor)}

View File

@@ -43,41 +43,36 @@ export const DateMeta = ({ item }) => {
}
};
function getDateMeta() {
let keys = Object.keys(item);
if (keys.includes("dateEdited"))
keys.splice(
keys.findIndex((k) => k === "dateModified"),
1
);
return keys.filter((key) => key.startsWith("date") && key !== "date");
}
const renderItem = (key) => (
<View
key={key}
style={{
flexDirection: "row",
justifyContent: "space-between",
paddingVertical: 3
}}
>
<Paragraph size={SIZE.xs + 1} color={colors.icon}>
{getNameFromKey(key)}
</Paragraph>
<Paragraph size={SIZE.xs + 1} color={colors.icon}>
{timeConverter(item[key])}
</Paragraph>
</View>
);
const renderItem = (key) =>
key.startsWith("date") && key !== "date" ? (
<View
key={key}
style={{
flexDirection: "row",
justifyContent: "space-between",
paddingVertical: 3
}}
>
<Paragraph size={SIZE.xs} color={colors.icon}>
{getNameFromKey(key)}
</Paragraph>
<Paragraph size={SIZE.xs} color={colors.icon}>
{timeConverter(item[key])}
</Paragraph>
</View>
) : null;
return (
<View
style={{
paddingVertical: 5,
marginTop: 5,
borderTopWidth: 1,
borderTopColor: colors.nav,
paddingHorizontal: 12
}}
>
{getDateMeta().map(renderItem)}
{Object.keys(item).map(renderItem)}
</View>
);
};

View File

@@ -27,32 +27,20 @@ import SearchService from "../../services/search";
import { useThemeStore } from "../../stores/use-theme-store";
import { COLORS_NOTE } from "../../utils/color-scheme";
import { SIZE } from "../../utils/size";
import SheetProvider from "../sheet-provider";
import { ReminderTime } from "../ui/reminder-time";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { ColorTags } from "./color-tags";
import { DateMeta } from "./date-meta";
import { DevMode } from "./dev-mode";
import { Items } from "./items";
import Notebooks from "./notebooks";
import { Synced } from "./synced";
import { Tags, TagStrip } from "./tags";
const Line = ({ top = 6, bottom = 6 }) => {
const colors = useThemeStore((state) => state.colors);
return (
<View
style={{
height: 1,
backgroundColor: colors.nav,
width: "100%",
marginTop: top,
marginBottom: bottom
}}
/>
);
};
import { Tags } from "./tags";
import { Topics } from "./topics";
import {
getUpcomingReminder
} from "@notesnook/core/collections/reminders";
import { ReminderTime } from "../ui/reminder-time";
export const Properties = ({
close = () => {},
item,
@@ -62,18 +50,13 @@ export const Properties = ({
const colors = useThemeStore((state) => state.colors);
const alias = item.alias || item.title;
const isColor = !!COLORS_NOTE[item.title];
const reminders = db.relations.from(item, "reminder");
const current = getUpcomingReminder(reminders);
const onScrollEnd = () => {
getRef().current?.handleChildScrollEnd();
};
if (!item || !item.id) {
return (
<Paragraph style={{ marginVertical: 10, alignSelf: "center" }}>
Start writing to save your note.
</Paragraph>
);
}
return (
<ScrollView
nestedScrollEnabled
@@ -88,53 +71,86 @@ export const Properties = ({
maxHeight: "100%"
}}
>
<View
style={{
paddingHorizontal: 12,
marginTop: 5,
zIndex: 10
}}
>
<Heading size={SIZE.lg}>
{item.type === "tag" && !isColor ? (
<Heading size={SIZE.xl} color={colors.accent}>
#
{!item || !item.id ? (
<Paragraph style={{ marginVertical: 10, alignSelf: "center" }}>
Start writing to save your note.
</Paragraph>
) : (
<View
style={{
marginTop: 5,
zIndex: 10
}}
>
<View
style={{
paddingHorizontal: 12
}}
>
<Heading size={SIZE.lg}>
{item.type === "tag" && !isColor ? (
<Heading size={SIZE.xl} color={colors.accent}>
#
</Heading>
) : null}
{alias}
</Heading>
{item.headline || item.description ? (
<Paragraph
style={{
marginBottom: 5
}}
numberOfLines={2}
color={colors.icon}
>
{(item.type === "notebook" ||
item.itemType === "notebook" ||
item.type === "reminder") &&
item?.description
? item.description
: null}
{(item.type === "note" || item.itemType === "note") &&
item?.headline
? item.headline
: null}
</Paragraph>
) : null}
{item.type === "reminder" ? (
<ReminderTime
reminder={item}
style={{
justifyContent: "flex-start",
borderWidth: 0,
height: 30,
alignSelf: "flex-start"
}}
fontSize={SIZE.xs + 1}
/>
) : null}
{item.type === "note" ? <Tags close={close} item={item} /> : null}
<Topics item={item} close={close} />
</View>
{item.type === "note" ? (
<Notebooks note={item} close={close} />
) : null}
{alias}
</Heading>
{item.type === "note" ? <TagStrip close={close} item={item} /> : null}
{item.type === "reminder" ? (
<ReminderTime
reminder={item}
style={{
justifyContent: "flex-start",
borderWidth: 0,
height: 30,
alignSelf: "flex-start",
backgroundColor: "transparent",
paddingHorizontal: 0
}}
fontSize={SIZE.xs + 1}
/>
) : null}
</View>
<Line top={12} />
<DateMeta item={item} />
<Line bottom={0} />
{item.type === "note" ? <Tags close={close} item={item} /> : null}
<DateMeta item={item} />
</View>
)}
<View
style={{
paddingHorizontal: 12
borderTopWidth: 1,
borderColor: colors.nav
}}
>
{item.notebooks ? <Notebooks note={item} close={close} /> : null}
</View>
/>
{item.type === "note" ? <ColorTags close={close} item={item} /> : null}
<Items
item={item}
@@ -156,7 +172,6 @@ export const Properties = ({
}}
/>
) : null}
<SheetProvider context="properties" />
</ScrollView>
);
};
@@ -169,50 +184,50 @@ Properties.present = (item, buttons = [], isSheet) => {
switch (type) {
case "trash":
props[0] = item;
props.push(["delete", "restore"]);
props.push(["PermDelete", "Restore"]);
break;
case "note":
android = Platform.OS === "android" ? ["pin-to-notifications"] : [];
android = Platform.OS === "android" ? ["PinToNotif"] : [];
props[0] = db.notes.note(item.id).data;
props.push([
"notebooks",
"add-reminder",
"share",
"export",
"copy",
"publish",
"pin",
"favorite",
"attachments",
"lock-unlock",
"trash",
"remove-from-topic",
"history",
"read-only",
"reminders",
"local-only",
"duplicate",
"Add to notebook",
"Add-Reminder",
"Share",
"Export",
"Copy",
"Publish",
"Pin",
"Favorite",
"Attachments",
"Vault",
"Delete",
"RemoveTopic",
"History",
"ReadOnly",
"Reminders",
"Local only",
"Duplicate",
...android,
...buttons
]);
break;
case "notebook":
props[0] = db.notebooks.notebook(item.id).data;
props.push(["edit-notebook", "pin", "add-shortcut", "trash"]);
props.push(["Edit Notebook", "Pin", "Add Shortcut", "Delete"]);
break;
case "topic":
props[0] = db.notebooks
.notebook(item.notebookId)
.topics.topic(item.id)._topic;
props.push(["move-notes", "edit-topic", "add-shortcut", "trash"]);
props.push(["Move notes", "Edit Topic", "Add Shortcut", "Delete"]);
break;
case "tag":
props[0] = db.tags.tag(item.id);
props.push(["add-shortcut", "trash", "rename-tag"]);
props.push(["Add Shortcut", "Delete", "Rename Tag"]);
break;
case "reminder": {
props[0] = db.reminders.reminder(item.id);
props.push(["edit-reminder", "trash", "disable-reminder"]);
props.push(["Edit reminder", "Delete", "ReminderOnOff"]);
break;
}
}

View File

@@ -33,19 +33,19 @@ export const Items = ({ item, buttons, close }) => {
const colors = useThemeStore((state) => state.colors);
const dimensions = useSettingStore((state) => state.dimensions);
const actions = useActions({ item, close });
const data = actions.filter((i) => buttons.indexOf(i.id) > -1 && !i.hidden);
const data = actions.filter((i) => buttons.indexOf(i.name) > -1 && !i.hidden);
let width = dimensions.width > 600 ? 600 : dimensions.width;
let columnItemsCount = DDS.isLargeTablet() ? 7 : 5;
let columnItemWidth = DDS.isTab
? (width - 12) / columnItemsCount
: (width - 12) / columnItemsCount;
? (width - 24) / columnItemsCount
: (width - 24) / columnItemsCount;
const _renderRowItem = ({ item }) => (
<View
onPress={item.func}
key={item.id}
testID={"icon-" + item.id}
key={item.name}
testID={"icon-" + item.name}
style={{
alignItems: "center",
width: columnItemWidth,
@@ -58,7 +58,7 @@ export const Items = ({ item, buttons, close }) => {
customStyle={{
height: columnItemWidth - 12,
width: columnItemWidth - 12,
borderRadius: 10,
borderRadius: 5,
justifyContent: "center",
alignItems: "center",
textAlign: "center",
@@ -72,14 +72,14 @@ export const Items = ({ item, buttons, close }) => {
color={
item.on
? colors.accent
: item.id.match(/(delete|trash)/g)
: item.name === "Delete" || item.name === "PermDelete"
? colors.errorText
: colors.icon
}
/>
</PressableButton>
<Paragraph size={SIZE.xs} style={{ textAlign: "center" }}>
<Paragraph size={SIZE.xs + 1} style={{ textAlign: "center" }}>
{item.title}
</Paragraph>
</View>
@@ -108,119 +108,31 @@ export const Items = ({ item, buttons, close }) => {
/>
);
const renderTopBarItem = ({ item }) => {
return (
<PressableButton
onPress={item.func}
key={item.id}
testID={"icon-" + item.id}
customStyle={{
alignItems: "center",
width: topBarItemWidth,
marginBottom: 10,
marginRight: 10,
backgroundColor: "transparent"
}}
>
<PressableButton
onPress={item.func}
type={item.on ? "shade" : "gray"}
customStyle={{
height: topBarItemWidth,
width: topBarItemWidth,
justifyContent: "center",
alignItems: "center",
textAlign: "center",
textAlignVertical: "center",
marginBottom: DDS.isTab ? 7 : 3.5,
borderRadius: 100
}}
>
<Icon
name={item.icon}
size={DDS.isTab ? SIZE.xxl : SIZE.md + 4}
color={
item.on
? colors.accent
: item.name === "Delete" || item.name === "PermDelete"
? colors.errorText
: colors.icon
}
/>
</PressableButton>
<Paragraph
size={SIZE.xxs + 1}
style={{ textAlign: "center" }}
textBreakStrategy="simple"
>
{item.title}
</Paragraph>
</PressableButton>
);
};
const topBarItemsList = [
"pin",
"favorite",
"copy",
"share",
"export",
"lock-unlock",
"publish"
];
const bottomBarItems = data.filter(
(item) => topBarItemsList.indexOf(item.id) > -1
);
const bottomGridItems = data.filter(
(item) => topBarItemsList.indexOf(item.id) === -1
);
const topBarItemWidth =
(width - (bottomBarItems.length * 10 + 14)) / bottomBarItems.length;
return item.type === "note" ? (
<>
<FlatList
data={bottomBarItems}
keyExtractor={(item) => item.title}
horizontal
disableVirtualization={true}
style={{
paddingHorizontal: 12,
paddingTop: 12
}}
renderItem={renderTopBarItem}
/>
<FlatList
data={bottomGridItems}
keyExtractor={(item) => item.title}
key={columnItemsCount + "key"}
numColumns={columnItemsCount}
disableVirtualization={true}
style={{
marginTop: item.type !== "note" ? 10 : 0,
paddingTop: 10
}}
columnWrapperStyle={{
justifyContent: "flex-start"
}}
contentContainerStyle={{
alignSelf: "center",
width: buttons.length < 5 ? "100%" : null,
paddingLeft: buttons.length < 5 ? 10 : 0
}}
renderItem={_renderRowItem}
/>
</>
<FlatList
data={data}
keyExtractor={(item) => item.title}
key={columnItemsCount + "key"}
numColumns={columnItemsCount}
style={{
marginTop: item.type !== "note" ? 10 : 0,
paddingTop: 10
}}
columnWrapperStyle={{
justifyContent: "flex-start"
}}
contentContainerStyle={{
alignSelf: "center",
width: buttons.length < 5 ? "100%" : null,
paddingLeft: buttons.length < 5 ? 10 : 0
}}
renderItem={_renderRowItem}
/>
) : (
<FlatList
data={data}
keyExtractor={(item) => item.title}
renderItem={renderColumnItem}
disableVirtualization={true}
/>
);
};

View File

@@ -23,34 +23,39 @@ import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { db } from "../../common/database";
import Notebook from "../../screens/notebook";
import { TopicNotes } from "../../screens/notes/topic-notes";
import { presentSheet, ToastEvent } from "../../services/event-manager";
import Navigation from "../../services/navigation";
import { useNotebookStore } from "../../stores/use-notebook-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
import { PressableButton } from "../ui/pressable";
import Heading from "../ui/typography/heading";
export default function Notebooks({ note, close, full }) {
export default function Notebooks({ note, close }) {
const colors = useThemeStore((state) => state.colors);
const notebooks = useNotebookStore((state) => state.notebooks);
function getNotebooks(item) {
if (!item.notebooks || item.notebooks.length < 1) return [];
let filteredNotebooks = [];
for (let notebookReference of item.notebooks) {
let notebook = {
...(notebooks.find((item) => item.id === notebookReference.id) || {})
};
if (notebook.id) {
notebook.topics = notebook.topics.filter((topic) => {
return notebookReference.topics.findIndex((t) => t === topic.id) > -1;
});
filteredNotebooks.push(notebook);
let notebooks = [];
for (let notebook of item.notebooks) {
let item_notebook = db.notebooks.notebook(notebook.id);
if (item_notebook) {
let data = {
id: notebook.id,
title: item_notebook.title,
topics: notebook.topics
.map((item) => {
let topic = item_notebook.topics.topic(item)?._topic;
if (!topic) return null;
return {
id: topic.id,
title: topic.title
};
})
.filter((i) => i !== null)
};
notebooks.push(data);
}
}
return filteredNotebooks;
return notebooks;
}
const noteNotebooks = getNotebooks(note);
const navigateNotebook = (id) => {
let item = db.notebooks.notebook(id)?.data;
@@ -64,139 +69,84 @@ export default function Notebooks({ note, close, full }) {
TopicNotes.navigate(item, true);
};
const renderItem = (item) => (
<View
key={item.id}
style={{
justifyContent: "flex-start",
paddingHorizontal: 12,
flexDirection: "row",
alignItems: "center",
flexShrink: 1,
flexGrow: 1,
padding: 6,
borderWidth: full ? 0 : 1,
borderColor: colors.nav,
borderRadius: 10,
backgroundColor: full ? "transparent" : colors.nav
}}
>
<Icon
name="book-outline"
color={colors.accent}
size={SIZE.sm}
style={{
marginRight: 5
}}
/>
<Heading
numberOfLines={1}
style={{
maxWidth: "50%"
}}
size={SIZE.sm}
onPress={() => {
navigateNotebook(item.id);
close();
}}
>
{item.title}
</Heading>
<ScrollView
horizontal={true}
showsHorizontalScrollIndicator={false}
style={{
flexDirection: "row",
marginLeft: 8,
borderLeftColor: colors.nav,
borderLeftWidth: 1,
paddingLeft: 8
}}
>
{item.topics.map((topic) => (
<Button
key={topic.id}
onPress={() => {
navigateTopic(topic.id, item.id);
close();
}}
onLongPress={async () => {
await db.notes.removeFromNotebook(
{
id: item.id,
topic: topic.id
},
note
);
useNotebookStore.getState().setNotebooks();
Navigation.queueRoutesForUpdate(
"Notes",
"Favorites",
"ColoredNotes",
"TaggedNotes",
"TopicNotes"
);
ToastEvent.show({
heading: "Note removed from topic",
context: "local",
type: "success"
});
}}
title={topic.title}
type="gray"
height={30}
fontSize={SIZE.xs + 1}
icon="bookmark-outline"
style={{
marginRight: 5,
borderRadius: 100,
paddingHorizontal: 8
}}
/>
))}
<View style={{ width: 10 }} />
</ScrollView>
</View>
);
return !note.notebooks || note.notebooks.length === 0 ? null : (
<View
style={{
width: "100%",
borderRadius: 10,
marginTop: 6
borderTopWidth: 1,
borderTopColor: colors.nav
}}
>
{full
? noteNotebooks.map(renderItem)
: noteNotebooks.slice(0, 1).map(renderItem)}
{noteNotebooks.length > 1 && !full ? (
<Button
title={`See all linked notebooks`}
fontSize={SIZE.xs + 1}
style={{
alignSelf: "flex-end",
marginRight: 12,
paddingHorizontal: 0,
backgroundColor: "transparent"
}}
type="gray"
textStyle={{
textDecorationLine: "underline"
}}
height={20}
{getNotebooks(note).map((item) => (
<PressableButton
key={item.id}
onPress={() => {
presentSheet({
context: "properties",
component: (ref, close) => (
<Notebooks note={note} close={close} full={true} />
)
});
navigateNotebook(item.id);
close();
}}
/>
) : undefined}
customStyle={{
justifyContent: "flex-start",
paddingHorizontal: 12,
flexDirection: "row",
alignItems: "center",
flexShrink: 1,
flexGrow: 1,
marginTop: 5,
paddingVertical: 6
}}
>
<Icon
name="book-outline"
color={colors.accent}
size={SIZE.sm + 1}
style={{
marginRight: 5
}}
/>
<Heading
numberOfLines={1}
style={{
maxWidth: "50%"
}}
size={SIZE.sm}
>
{item.title}
</Heading>
<ScrollView
horizontal={true}
showsHorizontalScrollIndicator={false}
style={{
flexDirection: "row",
marginLeft: 8,
borderLeftColor: colors.nav,
borderLeftWidth: 1,
paddingLeft: 8
}}
>
{item.topics.map((topic) => (
<Button
key={topic.id}
onPress={() => {
navigateTopic(topic.id, item.id);
close();
}}
title={topic.title}
type="grayBg"
height={22}
fontSize={SIZE.xs + 1}
icon="bookmark-outline"
style={{
marginRight: 5,
borderRadius: 100,
paddingHorizontal: 8
}}
/>
))}
<View style={{ width: 10 }} />
</ScrollView>
</PressableButton>
))}
</View>
);
}

View File

@@ -27,7 +27,6 @@ import { eOpenTagsDialog } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import { Button } from "../ui/button";
import { ColorTags } from "./color-tags";
export const Tags = ({ item, close }) => {
const colors = useThemeStore((state) => state.colors);
@@ -35,53 +34,41 @@ export const Tags = ({ item, close }) => {
<View
style={{
marginTop: 5,
paddingTop: 6,
paddingBottom: 6,
flexDirection: "row",
flexWrap: "wrap",
alignItems: "center",
paddingHorizontal: 12,
alignSelf: "center"
marginBottom: 5
}}
>
<Button
onPress={async () => {
close();
await sleep(300);
eSendEvent(eOpenTagsDialog, item);
}}
buttonType={{
text: colors.accent
}}
title="Add tags"
type="grayBg"
icon="plus"
iconPosition="right"
height={30}
fontSize={SIZE.xs + 1}
<View
style={{
marginRight: 5,
borderRadius: 100,
paddingHorizontal: 8
flexDirection: "row",
flexWrap: "wrap",
alignItems: "center"
}}
/>
<ColorTags item={item} />
</View>
) : null;
};
export const TagStrip = ({ item, close }) => {
return item.tags?.length > 0 ? (
<View
style={{
flexDirection: "row",
flexWrap: "wrap",
alignItems: "center"
}}
>
{item.tags.map((item) =>
item ? <TagItem key={item} tag={item} close={close} /> : null
)}
>
<Button
onPress={async () => {
close();
await sleep(300);
eSendEvent(eOpenTagsDialog, item);
}}
buttonType={{
text: colors.accent
}}
title="Add tags"
type="grayBg"
icon="plus"
iconPosition="right"
height={25}
fontSize={SIZE.xs + 1}
style={{
marginRight: 5,
borderRadius: 100,
paddingHorizontal: 8
}}
/>
{item.tags.map((item) =>
item ? <TagItem key={item} tag={item} close={close} /> : null
)}
</View>
</View>
) : null;
};
@@ -96,24 +83,23 @@ const TagItem = ({ tag, close }) => {
};
const style = {
paddingHorizontal: 0,
paddingHorizontal: 8,
marginVertical: 5,
borderRadius: 100,
marginRight: 10,
marginTop: 0,
backgroundColor: "transparent"
marginRight: 5
};
return (
<Button
onPress={onPress}
title={"#" + tag}
// buttonType={{
// text: colors.accent
// }}
type="grayBg"
height={20}
height={25}
fontSize={SIZE.xs + 1}
style={style}
textStyle={{
textDecorationLine: "underline"
}}
/>
);
};

View File

@@ -23,7 +23,6 @@ import { db } from "../../common/database";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { eSendEvent, ToastEvent } from "../../services/event-manager";
import Navigation from "../../services/navigation";
import SearchService from "../../services/search";
import useNavigationStore from "../../stores/use-navigation-store";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useThemeStore } from "../../stores/use-theme-store";
@@ -48,9 +47,7 @@ export const SelectionHeader = React.memo(() => {
const currentScreen = useNavigationStore((state) => state.currentScreen);
const screen = currentScreen.name;
const insets = useGlobalSafeAreaInsets();
SearchService.prepareSearch?.();
const allItems = SearchService.getSearchInformation()?.get() || [];
const allSelected = allItems.length === selectedItemsList.length;
useEffect(() => {
if (selectionMode) {
tabBarRef.current?.lock();
@@ -152,15 +149,14 @@ export const SelectionHeader = React.memo(() => {
<View
style={{
width: "100%",
height: Platform.OS === "android" ? 50 + insets.top : 50,
height: 50 + insets.top,
paddingTop: Platform.OS === "android" ? insets.top : null,
backgroundColor: colors.bg,
justifyContent: "space-between",
alignItems: "center",
flexDirection: "row",
zIndex: 999,
paddingHorizontal: 12,
marginVertical: 10
paddingHorizontal: 12
}}
>
<View
@@ -212,21 +208,20 @@ export const SelectionHeader = React.memo(() => {
alignItems: "center"
}}
>
<IconButton
{/* <ActionIcon
onPress={async () => {
useSelectionStore
.getState()
.setAll(allSelected ? [] : [...allItems]);
// await sleep(100);
// eSendEvent(eOpenMoveNoteDialog);
useSelectionStore.getState().setAll([...SearchService.getSearchInformation().data]);
}}
tooltipText="Select all"
tooltipPosition={4}
customStyle={{
marginLeft: 10
}}
color={allSelected ? colors.accent : colors.pri}
color={colors.pri}
name="select-all"
size={SIZE.xl}
/>
/> */}
{screen === "Trash" ||
screen === "Notebooks" ||
@@ -243,8 +238,6 @@ export const SelectionHeader = React.memo(() => {
marginLeft: 10
}}
color={colors.pri}
tooltipText="Add to notebooks"
tooltipPosition={4}
name="plus"
size={SIZE.xl}
/>
@@ -252,8 +245,6 @@ export const SelectionHeader = React.memo(() => {
onPress={async () => {
ExportNotesSheet.present(selectedItemsList);
}}
tooltipText="Export"
tooltipPosition={4}
customStyle={{
marginLeft: 10
}}
@@ -293,8 +284,6 @@ export const SelectionHeader = React.memo(() => {
customStyle={{
marginLeft: 10
}}
tooltipText="Remove from topic"
tooltipPosition={4}
testID="select-minus"
color={colors.pri}
name="minus"
@@ -308,8 +297,6 @@ export const SelectionHeader = React.memo(() => {
customStyle={{
marginLeft: 10
}}
tooltipText="Remove from favorites"
tooltipPosition={4}
color={colors.pri}
name="star-off"
size={SIZE.xl}
@@ -340,8 +327,6 @@ export const SelectionHeader = React.memo(() => {
return;
}}
color={colors.pri}
tooltipText="Move to trash"
tooltipPosition={1}
name="delete"
size={SIZE.xl}
/>
@@ -356,8 +341,6 @@ export const SelectionHeader = React.memo(() => {
color={colors.pri}
onPress={restoreItem}
name="delete-restore"
tooltipText="Restore"
tooltipPosition={4}
size={SIZE.xl - 3}
/>
@@ -367,8 +350,6 @@ export const SelectionHeader = React.memo(() => {
}}
color={colors.pri}
onPress={deleteItem}
tooltipText="Delete"
tooltipPosition={4}
name="delete"
size={SIZE.xl - 3}
/>

View File

@@ -58,7 +58,7 @@ const SheetProvider = ({ context = "global" }) => {
if (visible || dialogData) {
setDialogData(null);
setVisible(false);
await sleep(0);
await sleep(500);
}
setDialogData(data);
setVisible(true);

View File

@@ -1,33 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { createContext, useContext } from "react";
export const SelectionContext = createContext({
enabled: false,
selected: [],
toggleSelection: (item) => null,
deselect: (item) => null,
select: (item) => null,
isSelected: (item) => null,
setMultiSelect: () => null,
deselectAll: () => null
});
export const SelectionProvider = SelectionContext.Provider;
export const useSelectionContext = () => useContext(SelectionContext);

View File

@@ -1,75 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useCallback, useEffect, useRef, useState } from "react";
import { FlatList } from "react-native-gesture-handler";
import { db } from "../../../common/database";
import { ListHeaderInputItem } from "./list-header-item.js";
export const FilteredList = ({
data,
itemType,
onAddItem,
hasHeaderSearch,
...restProps
}) => {
const [filtered, setFiltered] = useState(data);
const query = useRef();
const onChangeText = useCallback(
(value) => {
query.current = value;
try {
if (!value) return setFiltered(data);
const results = db.lookup[itemType + "s"]([...data], value);
setFiltered(results);
} catch (e) {
console.warn(e.message);
}
},
[data, itemType]
);
const onSubmit = async (value) => {
return await onAddItem(value);
};
useEffect(() => {
onChangeText(query.current);
}, [data, onChangeText]);
return (
<FlatList
{...restProps}
data={filtered}
ListHeaderComponent={
hasHeaderSearch ? (
<ListHeaderInputItem
onSubmit={onSubmit}
onChangeText={onChangeText}
itemType={itemType}
testID={"list-input" + itemType}
placeholder={`Search or add a new ${itemType}`}
/>
) : null
}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
nestedScrollEnabled
/>
);
};

View File

@@ -17,15 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, {
createRef,
useCallback,
useEffect,
useMemo,
useState
} from "react";
import React, { createRef, useEffect, useState } from "react";
import { Keyboard, TouchableOpacity, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { FlatList } from "react-native-gesture-handler";
import { notesnook } from "../../../../e2e/test.ids";
import { db } from "../../../common/database";
import {
eSubscribeEvent,
@@ -37,17 +32,23 @@ import SearchService from "../../../services/search";
import { useNotebookStore } from "../../../stores/use-notebook-store";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { getTotalNotes } from "../../../utils";
import { eOpenMoveNoteDialog } from "../../../utils/events";
import layoutmanager from "../../../utils/layout-manager";
import { SIZE } from "../../../utils/size";
import { Dialog } from "../../dialog";
import DialogHeader from "../../dialog/dialog-header";
import { presentDialog } from "../../dialog/functions";
import { Button } from "../../ui/button";
import { IconButton } from "../../ui/icon-button";
import Input from "../../ui/input";
import { PressableButton } from "../../ui/pressable";
import SheetWrapper from "../../ui/sheet";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { SelectionProvider } from "./context";
import { FilteredList } from "./filtered-list";
import { ListItem } from "./list-item";
import { useCallback } from "react";
let newNotebookTitle = null;
const notebookInput = createRef();
const actionSheetRef = createRef();
const AddToNotebookSheet = () => {
const [visible, setVisible] = useState(false);
@@ -68,6 +69,7 @@ const AddToNotebookSheet = () => {
const _onClose = () => {
setVisible(false);
newNotebookTitle = null;
setNote(null);
Navigation.queueRoutesForUpdate(
"Notes",
@@ -91,37 +93,130 @@ export default AddToNotebookSheet;
const MoveNoteComponent = ({ note }) => {
const colors = useThemeStore((state) => state.colors);
const [multiSelect, setMultiSelect] = useState(false);
const notebooks = useNotebookStore((state) =>
state.notebooks.filter((n) => n?.type === "notebook")
);
const [edited, setEdited] = useState(false);
const selectedItemsList = useSelectionStore(
(state) => state.selectedItemsList
);
const setNotebooks = useNotebookStore((state) => state.setNotebooks);
const [itemState, setItemState] = useState({});
const onAddNotebook = async (title) => {
if (!title || title.trim().length === 0) {
ToastEvent.show({
const [expanded, setExpanded] = useState("");
const [notebookInputFocused, setNotebookInputFocused] = useState(false);
const [noteExists, setNoteExists] = useState([]);
const addNewNotebook = async () => {
if (!newNotebookTitle || newNotebookTitle.trim().length === 0)
return ToastEvent.show({
heading: "Notebook title is required",
type: "error",
context: "local"
});
let id = await db.notebooks.add({
title: newNotebookTitle,
description: null,
topics: [],
id: null
});
setExpanded(id);
openAddTopicDialog(db.notebooks.notebook(id).data);
notebookInput.current?.clear();
notebookInput.current?.blur();
setNotebooks();
updateNoteExists();
};
const addNewTopic = async (value, item) => {
if (!value || value.trim().length === 0) {
ToastEvent.show({
heading: "Topic title is required",
type: "error",
context: "local"
});
return false;
}
await db.notebooks.add({
title: title,
description: null,
topics: [],
id: null
});
await db.notebooks.notebook(item.id).topics.add(value);
setNotebooks();
updateNoteExists();
return true;
};
const handlePress = async (item) => {
let noteIds =
selectedItemsList.length > 0
? selectedItemsList.map((n) => n.id)
: [note?.id];
if (getCount(item)) {
await db.notes.removeFromNotebook(
{
id: item.notebookId,
topic: item.id
},
...noteIds
);
} else {
await db.notes.addToNotebook(
{
topic: item.id,
id: item.notebookId,
rebuildCache: true
},
...noteIds
);
}
Navigation.queueRoutesForUpdate(
"Notes",
"Favorites",
"ColoredNotes",
"TaggedNotes",
"TopicNotes"
);
setNotebooks();
updateNoteExists();
SearchService.updateAndSearch();
};
useEffect(() => {
updateNoteExists();
}, [updateNoteExists]);
const updateNoteExists = useCallback(() => {
if (!note?.id && selectedItemsList?.length === 0) return;
let notes =
selectedItemsList.length > 0
? selectedItemsList.map((n) => n.id)
: [note?.id];
let ids = [];
let notebooks = db.notebooks.all;
for (let i = 0; i < notebooks.length; i++) {
if (notebooks[i].topics) {
for (let t = 0; t < notebooks[i].topics.length; t++) {
let topic = notebooks[i].topics[t];
if (topic.type !== "topic") continue;
for (let id of notes) {
const noteIds = db.notes?.topicReferences.get(topic.id);
if (noteIds.indexOf(id) > -1) {
if (ids.indexOf(notebooks[i].id) === -1) {
ids.push(notebooks[i].id);
}
if (ids.indexOf(topic.id) === -1) ids.push(topic.id);
}
}
}
}
}
setNoteExists(ids);
}, [note?.id, selectedItemsList]);
const openAddTopicDialog = (item) => {
presentDialog({
context: "move_note",
@@ -131,223 +226,27 @@ const MoveNoteComponent = ({ note }) => {
paragraph: "Add a new topic in " + item.title,
positiveText: "Add",
positivePress: (value) => {
return onAddTopic(value, item);
return addNewTopic(value, item);
}
});
};
const onAddTopic = useCallback(
async (value, item) => {
if (!value || value.trim().length === 0) {
ToastEvent.show({
heading: "Topic title is required",
type: "error",
context: "local"
});
return false;
}
await db.notebooks.notebook(item.id).topics.add(value);
setNotebooks();
return true;
},
[setNotebooks]
);
// eslint-disable-next-line react-hooks/exhaustive-deps
const getSelectedNotesCountInItem = React.useCallback(
(item) => {
switch (item.type) {
case "notebook": {
const noteIds = [];
for (let topic of item.topics) {
noteIds.push(...(db.notes?.topicReferences.get(topic.id) || []));
}
let count = 0;
selectedItemsList.forEach((item) =>
noteIds.indexOf(item.id) > -1 ? count++ : undefined
);
return count;
}
case "topic": {
const noteIds = db.notes?.topicReferences.get(item.id);
let count = 0;
selectedItemsList.forEach((item) =>
noteIds.indexOf(item.id) > -1 ? count++ : undefined
);
return count;
}
}
},
[selectedItemsList]
);
useEffect(() => {
resetItemState();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const resetItemState = useCallback(
(state) => {
setItemState(() => {
const itemState = {};
const notebooks = db.notebooks.all;
for (let notebook of notebooks) {
itemState[notebook.id] = state
? state
: areAllSelectedItemsInAllTopics(notebook, selectedItemsList) &&
getSelectedNotesCountInItem(notebook, selectedItemsList) > 0
? "selected"
: getSelectedNotesCountInItem(notebook, selectedItemsList) > 0
? "intermediate"
: "deselected";
if (itemState[notebook.id] === "selected") {
contextValue.select(notebook);
}
for (let topic of notebook.topics) {
itemState[topic.id] = state
? state
: areAllSelectedItemsInTopic(topic, selectedItemsList) &&
getSelectedNotesCountInItem(topic, selectedItemsList)
? "selected"
: getSelectedNotesCountInItem(topic, selectedItemsList) > 0
? "intermediate"
: "deselected";
if (itemState[topic.id] === "selected") {
contextValue.select(topic);
}
}
}
return itemState;
});
},
[contextValue, getSelectedNotesCountInItem, selectedItemsList]
);
const getItemsForItem = (item) => {
switch (item.type) {
case "notebook":
return item.topics?.filter((t) => t.type === "topic");
}
};
function areAllSelectedItemsInAllTopics(notebook, items) {
return items.every((item) => {
return notebook.topics.every((topic) => {
return db.notes.topicReferences.get(topic.id).indexOf(item.id) > -1;
});
});
}
function areAllSelectedItemsInTopic(topic, items) {
return items.every((item) => {
return db.notes.topicReferences.get(topic.id).indexOf(item.id) > -1;
});
}
const updateItemState = useCallback(function (item, state) {
setItemState((itemState) => {
const mergeState = {
[item.id]: state
};
const notebooks = db.notebooks.all;
const notebook =
item.type === "notebook"
? item
: notebooks.find((n) => n.id === item.notebookId);
const intermediate = notebook.topics.some((topic) => {
return topic.id === item.id
? state === "selected"
: itemState[topic.id] === "selected";
});
if (intermediate) mergeState[notebook.id] = "intermediate";
const selected = notebook.topics.every((topic) => {
return topic.id === item.id
? state === "selected"
: itemState[topic.id] === "selected";
});
if (selected) mergeState[notebook.id] = "selected";
if (!selected && !intermediate) mergeState[notebook.id] = "deselected";
return {
...itemState,
...mergeState
};
});
}, []);
const contextValue = useMemo(
() => ({
enabled: multiSelect,
toggleSelection: (item) => {
setItemState((itemState) => {
if (itemState[item.id] === "selected") {
updateItemState(item, "deselected");
} else {
updateItemState(item, "selected");
}
return itemState;
});
},
setMultiSelect: setMultiSelect,
deselect: (item) => {
updateItemState(item, "deselected");
},
select: (item) => {
updateItemState(item, "selected");
},
deselectAll: (state) => {
resetItemState(state);
}
}),
[multiSelect, resetItemState, updateItemState]
);
const getItemFromId = (id) => {
for (const nb of notebooks) {
if (nb.id === id) return nb;
for (const tp of nb.topics) {
if (tp.id === id) return tp;
const getCount = (topic) => {
if (!topic) return;
let notes =
selectedItemsList.length > 0
? selectedItemsList.map((n) => n.id)
: [note?.id];
let count = 0;
for (let id of notes) {
const noteIds = db.notes?.topicReferences.get(topic.id);
if (noteIds.indexOf(id) > -1) {
count++;
}
}
};
const onSave = async () => {
for (const id in itemState) {
const item = getItemFromId(id);
if (item.type === "notebook") continue;
const noteIds = selectedItemsList.map((n) => n.id);
if (itemState[id] === "selected") {
await db.notes.addToNotebook(
{
topic: item.id,
id: item.notebookId,
rebuildCache: true
},
...noteIds
);
} else if (itemState[id] === "deselected") {
await db.notes.removeFromNotebook(
{
id: item.notebookId,
topic: item.id,
rebuildCache: true
},
...noteIds
);
}
}
Navigation.queueRoutesForUpdate(
"Notes",
"Favorites",
"ColoredNotes",
"TaggedNotes",
"TopicNotes"
);
setNotebooks();
SearchService.updateAndSearch();
actionSheetRef.current?.hide();
return count > 0 && notes.length > 0
? `${count} of ${notes.length} selected notes exist in this topic. (Tap to remove)`
: null;
};
return (
@@ -367,162 +266,215 @@ const MoveNoteComponent = ({ note }) => {
<View
style={{
paddingHorizontal: 12,
justifyContent: "space-between",
flexDirection: "row",
alignItems: "flex-start"
justifyContent: "space-between"
}}
>
<DialogHeader
style={{
minHeight: 10,
flexShrink: 1
}}
title="Select notebooks"
paragraph={
!multiSelect
? "Long press to enable multi-select."
: "Select topics you want to add note(s) to."
}
/>
<Button
height={35}
style={{
borderRadius: 100,
paddingHorizontal: 24,
alignSelf: "flex-start"
}}
title="Save"
type={"accent"}
onPress={onSave}
title="Add to notebook"
paragraph={"Add your notes to notebooks to find them easily."}
/>
</View>
{multiSelect ? (
<View
style={{
paddingHorizontal: 12
}}
>
<Button
title="Reset selection"
height={30}
<FlatList
nestedScrollEnabled={true}
onMomentumScrollEnd={() => {
actionSheetRef.current?.handleChildScrollEnd();
}}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
data={notebooks}
ListFooterComponent={
<View
style={{
alignSelf: "flex-start",
paddingHorizontal: 0
}}
onPress={() => {
resetItemState();
setMultiSelect(false);
height: 200
}}
/>
</View>
) : null}
<SelectionProvider value={contextValue}>
<FilteredList
onMomentumScrollEnd={() => {
actionSheetRef.current?.handleChildScrollEnd();
}}
style={{
paddingHorizontal: 12
}}
ListEmptyComponent={
notebooks.length > 0 ? null : (
}
ListHeaderComponent={
<View
style={{
width: "100%",
marginTop: 10
}}
>
<Input
fwdRef={notebookInput}
onChangeText={(value) => {
newNotebookTitle = value;
}}
testID={notesnook.ids.dialogs.addTo.addNotebook}
blurOnSubmit={false}
onFocusInput={() => {
setNotebookInputFocused(true);
}}
onBlurInput={() => {
setNotebookInputFocused(false);
}}
button={{
icon: "check",
color: notebookInputFocused ? colors.accent : colors.icon,
onPress: addNewNotebook
}}
onSubmit={addNewNotebook}
placeholder="Create a new notebook"
/>
</View>
}
style={{
paddingHorizontal: 12
}}
renderItem={({ item }) => (
<View
style={{
borderWidth: 1,
borderColor: expanded ? colors.nav : "transparent",
borderRadius: 6,
overflow: "hidden",
marginBottom: 10
}}
>
<PressableButton
onPress={() => {
if (!item.topics || item.topics.length === 0) {
setExpanded(item.id);
openAddTopicDialog(item);
return;
}
layoutmanager.withAnimation(200);
setExpanded(item.id === expanded ? null : item.id);
setNotebookInputFocused(false);
}}
type="grayBg"
customStyle={{
height: 50,
width: "100%",
borderRadius: 5,
alignItems: "flex-start"
}}
>
<View
style={{
width: "100%",
height: "100%",
justifyContent: "center",
alignItems: "center"
height: 50,
justifyContent: "space-between",
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 12
}}
>
<Icon name="book-outline" color={colors.icon} size={100} />
<Paragraph style={{ marginBottom: 10 }}>
You do not have any notebooks.
</Paragraph>
<View>
<Heading
color={
noteExists.indexOf(item.id) > -1 ? colors.accent : null
}
size={SIZE.md}
>
{item.title}
</Heading>
{item.topics?.length > 0 ? (
<Paragraph size={SIZE.xs} color={colors.icon}>
{getTotalNotes(item) + " notes" + " & "}
{item.topics.length === 1
? item.topics.length + " topic"
: item.topics.length + " topics"}
</Paragraph>
) : null}
</View>
<IconButton
name={expanded === item.id ? "plus" : "chevron-down"}
color={expanded === item.id ? colors.accent : colors.pri}
size={SIZE.xl}
onPress={() => {
if (expanded !== item.id) {
setExpanded(item.id);
return;
}
layoutmanager.withAnimation(200);
setExpanded(item.id);
openAddTopicDialog(item);
}}
/>
</View>
)
}
data={notebooks}
hasHeaderSearch={true}
renderItem={({ item, index }) => (
<ListItem
item={item}
key={item.id}
index={index}
intermediate={itemState[item.id] === "intermediate"}
removed={
itemState[item.id] === "deselected" &&
getSelectedNotesCountInItem(item) > 0
}
isSelected={itemState[item.id] === "selected"}
infoText={
<>
{item.topics.length === 1
? item.topics.length + " topic"
: item.topics.length + " topics"}
</>
}
getListItems={getItemsForItem}
getSublistItemProps={(topic) => ({
selected: itemState[topic.id] === "selected",
intermediate: itemState[topic.id] === "intermediate",
isSelected: itemState[topic.id] === "selected",
removed:
itemState[topic.id] === "deselected" &&
getSelectedNotesCountInItem(topic) > 0,
style: {
marginBottom: 0,
height: 40
},
onPress: (item) => {
const currentState = itemState[item.id];
if (currentState !== "selected") {
resetItemState("deselected");
contextValue.select(item);
updateItemState(
notebooks.find((n) => n.id === item.notebookId),
"intermediate"
);
} else {
contextValue.deselect(item);
}
},
key: item.id,
type: "transparent"
})}
icon={(expanded) => ({
name: expanded ? "chevron-up" : "chevron-down",
color: expanded ? colors.accent : colors.pri
})}
onScrollEnd={() => {
actionSheetRef.current?.handleChildScrollEnd();
}}
hasSubList={true}
hasHeaderSearch={false}
type="grayBg"
sublistItemType="topic"
onAddItem={(title) => {
return onAddTopic(title, item);
}}
onAddSublistItem={(item) => {
openAddTopicDialog(item);
}}
/>
)}
itemType="notebook"
onAddItem={async (title) => {
return await onAddNotebook(title);
}}
ListFooterComponent={
<View
style={{
height: 200
}}
/>
}
/>
</SelectionProvider>
</PressableButton>
{expanded === item.id ? (
<FlatList
nestedScrollEnabled
data={item.topics?.filter((t) => t.type === "topic")}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
onMomentumScrollEnd={() => {
actionSheetRef.current?.handleChildScrollEnd();
}}
style={{
width: "100%",
alignSelf: "flex-end",
maxHeight: 500
}}
renderItem={({ item, index }) => (
<PressableButton
onPress={() => handlePress(item, index)}
type="gray"
customStyle={{
minHeight: 50,
borderTopWidth: index === 0 ? 0 : 1,
borderTopColor: index === 0 ? null : colors.nav,
width: "100%",
borderRadius: 0,
alignItems: "center",
flexDirection: "row",
paddingHorizontal: 12,
justifyContent: "space-between",
paddingVertical: 12
}}
>
<View>
<Paragraph color={colors.heading}>
{item.title}
</Paragraph>
<Paragraph color={colors.icon} size={SIZE.xs}>
{getTotalNotes(item) + " notes"}
</Paragraph>
{getCount(item) ? (
<View
style={{
backgroundColor: colors.nav,
borderRadius: 5,
paddingHorizontal: 5,
paddingVertical: 2,
marginTop: 5
}}
>
<Paragraph color={colors.icon} size={SIZE.xs}>
{getCount(item)}
</Paragraph>
</View>
) : null}
</View>
{noteExists.indexOf(item.id) > -1 ? (
<Button
onPress={() => handlePress(item, index)}
icon="check"
testID="icon-check"
iconColor={colors.accent}
iconSize={SIZE.lg}
height={35}
width={35}
style={{
borderRadius: 100,
paddingHorizontal: 0
}}
/>
) : null}
</PressableButton>
)}
/>
) : null}
</View>
)}
/>
</View>
</>
);

View File

@@ -1,87 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useRef, useState } from "react";
import { View } from "react-native";
import { useThemeStore } from "../../../stores/use-theme-store";
import Input from "../../ui/input";
import Paragraph from "../../ui/typography/paragraph";
export const ListHeaderInputItem = ({
onSubmit,
onChangeText,
placeholder,
testID
}) => {
const [focused, setFocused] = useState(false);
const colors = useThemeStore((state) => state.colors);
const [inputValue, setInputValue] = useState();
const inputRef = useRef();
return (
<View
style={{
width: "100%",
marginTop: 10,
marginBottom: 5
}}
>
<Input
fwdRef={inputRef}
onChangeText={(value) => {
setInputValue(value);
onChangeText?.(value);
}}
testID={testID}
blurOnSubmit={false}
onFocusInput={() => {
setFocused(true);
}}
onBlurInput={() => {
setFocused(false);
}}
button={{
icon: inputValue ? "plus" : "magnify",
color: focused ? colors.accent : colors.icon,
onPress: async () => {
const result = await onSubmit(inputValue);
if (result) {
inputRef.current?.blur();
}
}
}}
placeholder={placeholder}
marginBottom={5}
/>
{inputValue ? (
<View
style={{
backgroundColor: colors.shade,
padding: 5,
borderRadius: 5,
marginBottom: 10
}}
>
<Paragraph color={colors.accent}>
Tap on + to add {`"${inputValue}"`}
</Paragraph>
</View>
) : null}
</View>
);
};

View File

@@ -1,233 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useState } from "react";
import { View } from "react-native";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
import { IconButton } from "../../ui/icon-button";
import { PressableButton } from "../../ui/pressable";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { useSelectionContext } from "./context";
import { FilteredList } from "./filtered-list";
const _ListItem = ({
item,
index,
icon,
infoText,
intermediate,
hasSubList,
onPress,
onScrollEnd,
getListItems,
style,
type,
sublistItemType,
onAddItem,
getSublistItemProps,
removed,
isSelected,
hasHeaderSearch,
onAddSublistItem
}) => {
const { enabled, toggleSelection, setMultiSelect, select, deselect } =
useSelectionContext();
const colors = useThemeStore((state) => state.colors);
const [expanded, setExpanded] = useState(false);
function selectItem() {
const currentState = isSelected;
toggleSelection(item);
if (item.type === "notebook") {
item.topics.forEach((item) => {
if (currentState) {
deselect(item);
} else {
select(item);
}
});
}
}
return (
<View
style={{
overflow: "hidden",
marginBottom: 10,
...style
}}
>
<PressableButton
onPress={() => {
if (hasSubList) return setExpanded(!expanded);
if (enabled) return selectItem();
onPress?.(item);
}}
type={type}
onLongPress={() => {
setMultiSelect(true);
selectItem();
}}
customStyle={{
height: style?.height || 50,
width: "100%",
alignItems: "flex-start"
}}
>
<View
style={{
width: "100%",
height: 50,
justifyContent: "space-between",
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 12
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center"
}}
>
<IconButton
size={22}
customStyle={{
marginRight: 5,
width: 23,
height: 23
}}
color={
removed
? colors.red
: intermediate || isSelected
? colors.accent
: colors.icon
}
onPress={() => {
if (item.type === "notebook") {
setMultiSelect(true);
}
selectItem();
if (enabled) return;
onPress?.(item);
}}
testID={
removed
? "close-circle-outline"
: isSelected
? "check-circle-outline"
: intermediate
? "minus-circle-outline"
: "checkbox-blank-circle-outline"
}
name={
removed
? "close-circle-outline"
: isSelected
? "check-circle-outline"
: intermediate
? "minus-circle-outline"
: "checkbox-blank-circle-outline"
}
/>
<View>
{hasSubList && expanded ? (
<Heading size={SIZE.md}>{item.title}</Heading>
) : (
<Paragraph size={SIZE.sm}>{item.title}</Paragraph>
)}
{infoText ? (
<Paragraph size={SIZE.xs} color={colors.icon}>
{infoText}
</Paragraph>
) : null}
</View>
</View>
<View
style={{
flexDirection: "row"
}}
>
{onAddSublistItem ? (
<IconButton
name={"plus"}
testID="add-item-icon"
color={colors}
size={SIZE.xl}
onPress={() => {
onAddSublistItem(item);
}}
/>
) : null}
{icon ? (
<IconButton
name={icon(expanded).name}
color={icon(expanded).color}
size={icon(expanded).size || SIZE.xl}
onPress={
hasSubList
? () => setExpanded(!expanded)
: icon(expanded).onPress
}
/>
) : null}
</View>
</View>
</PressableButton>
{expanded && hasSubList ? (
<FilteredList
nestedScrollEnabled
data={getListItems(item)}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
onMomentumScrollEnd={onScrollEnd}
style={{
width: "95%",
alignSelf: "flex-end",
maxHeight: 500
}}
itemType={sublistItemType}
hasHeaderSearch={hasHeaderSearch}
renderItem={({ item, index }) => (
<ListItem
item={item}
{...getSublistItemProps(item)}
index={index}
onScrollEnd={onScrollEnd}
/>
)}
onAddItem={onAddItem}
/>
) : null}
</View>
);
};
export const ListItem = React.memo(_ListItem, (prev, next) => {
if (prev.selected === undefined) return false;
if (prev.isSelected !== next.isSelected) return false;
if (prev.selected !== next.selected) return false;
if (prev.intermediate !== next.intermediate) return false;
return true;
});

View File

@@ -94,9 +94,9 @@ NewFeature.present = () => {
return;
}
if (version && version === getVersion()) return false;
SettingsService.set({
version: getVersion()
});
// SettingsService.set({
// version: getVersion()
// });
const _features = features?.filter(
(feature) => !feature.platform || feature.platform === Platform.OS
);

View File

@@ -46,8 +46,6 @@ import SettingsService from "../../../services/settings";
import { useRelationStore } from "../../../stores/use-relation-store";
import { ReminderTime } from "../../ui/reminder-time";
import Paragraph from "../../ui/typography/paragraph";
import { NoteType } from "../../../utils/types";
import { Dialog } from "../../dialog";
type ReminderSheetProps = {
actionSheetRef: RefObject<ActionSheet>;
@@ -121,10 +119,6 @@ export default function ReminderSheet({
const details = useRef<string | undefined>(reminder?.description);
const titleRef = useRef<TextInput>(null);
const { height } = useWindowDimensions();
const referencedItem = reference
? (db.notes?.note(reference.id)?.data as NoteType)
: null;
const showDatePicker = () => {
setDatePickerVisibility(true);
};
@@ -162,7 +156,7 @@ export default function ReminderSheet({
async function saveReminder() {
try {
if (!(await Notifications.checkAndRequestPermissions(true)))
if (!(await Notifications.checkAndRequestPermissions()))
throw new Error(
"App does not have permission to schedule notifications"
);
@@ -233,7 +227,6 @@ export default function ReminderSheet({
paddingHorizontal: 12
}}
>
<Dialog context="local"/>
<ScrollView
onScrollEndDrag={() => actionSheetRef.current?.handleChildScrollEnd()}
style={{
@@ -242,31 +235,17 @@ export default function ReminderSheet({
>
<Input
fwdRef={titleRef}
defaultValue={reminder?.title || referencedItem?.title}
defaultValue={reminder?.title}
placeholder="Remind me of..."
onChangeText={(text) => (title.current = text)}
containerStyle={{ borderWidth: 0, borderBottomWidth: 1 }}
/>
<Input
defaultValue={reminder ? reminder?.description : referencedItem?.headline}
defaultValue={reminder?.description}
placeholder="Add a quick note"
onChangeText={(text) => (details.current = text)}
containerStyle={{
borderWidth: 0,
borderBottomWidth: 1,
maxHeight: 80,
marginTop: 10
}}
multiline
textAlignVertical="top"
inputStyle={{
height: 80
}}
height={80}
wrapperStyle={{
marginBottom: 20
}}
containerStyle={{ borderWidth: 0, borderBottomWidth: 1 }}
/>
<View

View File

@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React, { useCallback } from "react";
import { FlatList, View } from "react-native";
import { notesnook } from "../../../e2e/test.ids";
import umami from "../../common/analytics";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { DDS } from "../../services/device-detection";
import { eSendEvent } from "../../services/event-manager";
@@ -75,6 +76,7 @@ export const SideMenu = React.memo(
name: "Notesnook Pro",
icon: "crown",
func: () => {
umami.pageView("/pro-screen", "/sidemenu");
eSendEvent(eOpenPremiumDialog);
}
};

View File

@@ -73,7 +73,6 @@ interface InputProps extends TextInputProps {
buttonLeft?: React.ReactNode;
inputStyle?: TextInputProps["style"];
containerStyle?: ViewStyle;
wrapperStyle?: ViewStyle;
flexGrow?: number;
}
@@ -101,7 +100,6 @@ const Input = ({
flexGrow = 1,
inputStyle = {},
containerStyle = {},
wrapperStyle = {},
...restProps
}: InputProps) => {
const colors = useThemeStore((state) => state.colors);
@@ -238,8 +236,7 @@ const Input = ({
marginBottom: marginBottom,
flexGrow: flexGrow,
maxHeight: height,
marginRight: marginRight,
...wrapperStyle
marginRight: marginRight
}}
>
<TouchableOpacity

View File

@@ -59,8 +59,8 @@ const SheetWrapper = ({
zIndex: 10,
paddingTop: 5,
paddingBottom: 0,
borderTopRightRadius: 20,
borderTopLeftRadius: 20,
borderTopRightRadius: 10,
borderTopLeftRadius: 10,
alignSelf: "center",
borderBottomRightRadius: 0,
borderBottomLeftRadius: 0
@@ -104,12 +104,12 @@ const SheetWrapper = ({
ExtraOverlayComponent={
<>
{overlay}
<Toast context="local" />
<PremiumToast
context="sheet"
close={() => fwdRef?.current?.hide()}
offset={50}
/>
<Toast context="local" />
</>
}
onClose={_onClose}

View File

@@ -19,4 +19,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { FeatureType } from "./components/sheets/new-feature";
export const features: FeatureType[] = [];
export const features: FeatureType[] = [
{
title: "Cross platform Reminders 🔔",
body: "Finally reminders are here. You can set reminders on notes or independently. Go to Side Menu > Reminders to set your first reminder!"
},
{
title: "Multi-factor auth by default",
body: "Multi-factor auth is enabled by default for all users to improve login security."
},
{
title: "Change account email",
body: "Now you can go to Settings > Account Settings to change your email."
},
{
title: "Sync settings",
body: "Added options to disable sync, auto-sync & real-time sync from settings."
},
{
title: "Improved PDF exports styling",
body: "Tables, checklists, codeblocks, quotes are now properly formatted in PDF exports."
}
];

View File

@@ -21,6 +21,7 @@ import Clipboard from "@react-native-clipboard/clipboard";
import React, { useCallback, useEffect, useState } from "react";
import { Platform } from "react-native";
import Share from "react-native-share";
import { notesnook } from "../../e2e/test.ids";
import { db } from "../common/database";
import { presentDialog } from "../components/dialog/functions";
import NoteHistory from "../components/note-history";
@@ -601,49 +602,22 @@ export const useActions = ({ close = () => null, item }) => {
};
const actions = [
{
id: "notebooks",
title: "Link Notebooks",
name: "Add to notebook",
title: "Add to notebook",
icon: "book-outline",
func: addTo
},
{
id: "add-tag",
title: "Add tags",
icon: "pound",
func: addTo
},
{
id: "add-reminder",
title: "Remind me",
icon: "clock-plus-outline",
name: "Add-Reminder",
title: "Add reminder",
icon: "bell-plus",
func: () => {
ReminderSheet.present(null, { id: item.id, type: "note" });
},
close: true
},
{
id: "lock-unlock",
title: item.locked ? "Unlock" : "Lock",
icon: item.locked ? "lock-open-outline" : "key-outline",
func: addToVault,
on: item.locked
},
{
id: "publish",
title: isPublished ? "Published" : "Publish",
icon: "cloud-upload-outline",
on: isPublished,
func: publishNote
},
{
id: "export",
title: "Export",
icon: "export",
func: exportNote
},
{
id: "move-notes",
name: "Move notes",
title: "Add notes",
icon: "plus",
func: async () => {
@@ -652,40 +626,43 @@ export const useActions = ({ close = () => null, item }) => {
MoveNotes.present(db.notebooks.notebook(item.notebookId).data, item);
}
},
{
id: "pin",
title: item.pinned ? "Unpin" : "Pin",
name: "Pin",
title: item.pinned ? "Unpin" : "Pin to top",
icon: item.pinned ? "pin-off-outline" : "pin-outline",
func: pinItem,
close: false,
check: true,
on: item.pinned,
pro: true
nopremium: true,
id: notesnook.ids.dialogs.actionsheet.pin
},
{
id: "favorite",
name: "Favorite",
title: !item.favorite ? "Favorite" : "Unfavorite",
icon: item.favorite ? "star-off" : "star-outline",
func: addToFavorites,
close: false,
check: true,
on: item.favorite,
pro: true,
nopremium: true,
id: notesnook.ids.dialogs.actionsheet.favorite,
color: "orange"
},
{
id: "pin-to-notifications",
name: "PinToNotif",
title:
notifPinned !== null
? "Unpin from Notifications"
: "Pin to notifications",
icon: "message-badge-outline",
: "Pin to Notifications",
icon: "bell",
on: notifPinned !== null,
func: pinToNotifications
},
{
id: "edit-notebook",
name: "Edit Notebook",
title: "Edit notebook",
icon: "square-edit-outline",
func: async () => {
@@ -695,7 +672,7 @@ export const useActions = ({ close = () => null, item }) => {
}
},
{
id: "edit-topic",
name: "Edit Topic",
title: "Edit topic",
icon: "square-edit-outline",
func: async () => {
@@ -708,72 +685,131 @@ export const useActions = ({ close = () => null, item }) => {
}
},
{
id: "copy",
name: "Copy",
title: "Copy",
icon: "content-copy",
func: copyContent
},
{
id: "restore",
name: "Restore",
title: "Restore " + item.itemType,
icon: "delete-restore",
func: restoreTrashItem
},
{
id: "add-shortcut",
name: "Publish",
title: isPublished ? "Published" : "Publish",
icon: "cloud-upload-outline",
on: isPublished,
func: publishNote
},
{
name: "Vault",
title: item.locked ? "Remove from vault" : "Add to vault",
icon: item.locked ? "shield-off-outline" : "shield-outline",
func: addToVault,
on: item.locked
},
{
name: "Add Shortcut",
title: isPinnedToMenu ? "Remove Shortcut" : "Add Shortcut",
icon: isPinnedToMenu ? "link-variant-remove" : "link-variant",
func: createMenuShortcut,
close: false,
check: true,
on: isPinnedToMenu,
pro: true
nopremium: true,
id: notesnook.ids.dialogs.actionsheet.pinMenu
},
{
id: "rename-tag",
name: "Rename Tag",
title: "Rename tag",
icon: "square-edit-outline",
func: renameTag
},
{
id: "share",
name: "Share",
title: "Share",
icon: "share-variant",
func: shareNote
},
{
id: "read-only",
name: "Attachments",
title: "Attachments",
icon: "attachment",
func: showAttachments
},
{
name: "Export",
title: "Export",
icon: "export",
func: exportNote
},
{
name: "RemoveTopic",
title: "Remove from topic",
hidden: !isNoteInTopic(),
icon: "minus-circle-outline",
func: removeNoteFromTopic
},
{
name: "Delete",
title:
item.type !== "notebook" && item.type !== "note"
? "Delete " + item.type
: "Move to trash",
icon: "delete-outline",
type: "error",
func: deleteItem
},
{
name: "PermDelete",
title: "Delete " + item.itemType,
icon: "delete",
func: deleteTrashItem
},
{
name: "ReadOnly",
title: "Read only",
icon: "pencil-lock",
func: toggleReadyOnlyMode,
on: item.readonly
},
{
id: "local-only",
name: "Local only",
title: "Local only",
icon: "sync-off",
func: toggleLocalOnly,
on: item.localOnly
},
{
id: "duplicate",
name: "History",
title: "History",
icon: "history",
func: openHistory
},
{
name: "Duplicate",
title: "Duplicate",
icon: "content-duplicate",
func: duplicateNote
},
{
id: "dark-mode",
name: "Dark Mode",
title: "Dark mode",
icon: "theme-light-dark",
func: switchTheme,
switch: true,
on: colors.night ? true : false,
close: false,
pro: true
nopremium: true,
id: notesnook.ids.dialogs.actionsheet.night
},
{
id: "edit-reminder",
name: "Edit reminder",
title: "Edit reminder",
icon: "pencil",
func: async () => {
@@ -783,11 +819,10 @@ export const useActions = ({ close = () => null, item }) => {
},
close: false
},
{
id: "reminders",
name: "Reminders",
title: "Reminders",
icon: "clock-outline",
icon: "bell",
func: async () => {
close();
RelationsList.present({
@@ -807,20 +842,7 @@ export const useActions = ({ close = () => null, item }) => {
close: false
},
{
id: "attachments",
title: "Attachments",
icon: "attachment",
func: showAttachments
},
{
id: "history",
title: "History",
icon: "history",
func: openHistory
},
{
id: "disable-reminder",
name: "ReminderOnOff",
title: !item.disabled ? "Turn off reminder" : "Turn on reminder",
icon: !item.disabled ? "bell-off-outline" : "bell",
func: async () => {
@@ -841,32 +863,9 @@ export const useActions = ({ close = () => null, item }) => {
"Reminders"
);
}
},
{
id: "remove-from-topic",
title: "Remove from topic",
hidden: !isNoteInTopic(),
icon: "minus-circle-outline",
func: removeNoteFromTopic
},
{
id: "trash",
title:
item.type !== "notebook" && item.type !== "note"
? "Delete " + item.type
: "Move to trash",
icon: "delete-outline",
type: "error",
func: deleteItem
},
{
id: "delete",
title: "Delete " + item.itemType,
icon: "delete",
func: deleteTrashItem
}
// {
// id: "ReferencedIn",
// name: "ReferencedIn",
// title: "References",
// icon: "link",
// func: async () => {

View File

@@ -26,13 +26,12 @@ import {
Linking,
NativeEventEmitter,
NativeModules,
Platform,
Keyboard
Platform
} from "react-native";
import * as RNIap from "react-native-iap";
import { enabled } from "react-native-privacy-snapshot";
import { Walkthrough } from "../components/walkthroughs";
import { editorController, editorState } from "../screens/editor/tiptap/utils";
import { editorState } from "../screens/editor/tiptap/utils";
import {
clearMessage,
setEmailVerifyMessage,
@@ -70,7 +69,6 @@ import { clearAppState } from "../screens/editor/tiptap/utils";
import { tabBarRef } from "../utils/global-refs";
import BackupService from "../services/backup";
import { sleep } from "../utils/time";
import notifee from "@notifee/react-native";
const SodiumEventEmitter = new NativeEventEmitter(NativeModules.Sodium);
export const useAppEvents = () => {
@@ -318,10 +316,6 @@ export const useAppEvents = () => {
const onLogout = async (reason) => {
console.log("Logged out", reason);
DatabaseLogger.log("User Logged Out" + reason);
SettingsService.set({
introCompleted: true
});
};
const unsubIAP = () => {
@@ -450,7 +444,6 @@ export const useAppEvents = () => {
const onAppStateChanged = useCallback(
async (state) => {
if (state === "active") {
notifee.setBadgeCount(0);
updateStatusBarColor();
if (
SettingsService.get().appLockMode !== "background" &&
@@ -495,10 +488,6 @@ export const useAppEvents = () => {
!useUserStore.getState().verifyUser
) {
useUserStore.getState().setVerifyUser(true);
if (Platform.OS === "ios") {
editorController.current?.commands.blur();
Keyboard.dismiss();
}
}
if (
SettingsService.get().privacyScreen ||

View File

@@ -28,14 +28,13 @@ import { Button } from "../../components/ui/button";
import { IconButton } from "../../components/ui/icon-button";
import Paragraph from "../../components/ui/typography/paragraph";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import { DDS } from "../../services/device-detection";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
import { useThemeStore } from "../../stores/use-theme-store";
import { eClearEditor } from "../../utils/events";
import { eClearEditor, eOnLoadNote } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { editorState } from "./tiptap/utils";
const EditorOverlay = ({ editorId = "", editor }) => {
@@ -65,8 +64,13 @@ const EditorOverlay = ({ editorId = "", editor }) => {
opacity.value = 1;
translateValue.value = 0;
timers.current.error = setTimeout(() => {
if (_loading) {
let note = _loading;
note.forced = true;
eSendEvent(eOnLoadNote + editorId, note);
}
setError(true);
}, 15 * 1000);
}, 4000);
} else {
clearTimers();
setTimeout(() => {
@@ -81,7 +85,7 @@ const EditorOverlay = ({ editorId = "", editor }) => {
}, 100);
}
},
[opacity, translateValue]
[editorId, opacity, translateValue]
);
useEffect(() => {
@@ -140,19 +144,15 @@ const EditorOverlay = ({ editorId = "", editor }) => {
paddingRight: 12
}}
>
{DDS.isTablet() ? (
<View />
) : (
<IconButton
onPress={() => {
eSendEvent(eClearEditor);
opacity.value = 0;
translateValue.value = 6000;
}}
name="arrow-left"
color={colors.pri}
/>
)}
<IconButton
onPress={() => {
eSendEvent(eClearEditor);
opacity.value = 0;
translateValue.value = 6000;
}}
name="arrow-left"
color={colors.pri}
/>
<View
style={{

View File

@@ -28,9 +28,8 @@ import {
NativeEventSubscription
} from "react-native";
import { WebViewMessageEvent } from "react-native-webview";
import umami from "../../../common/analytics/index";
import { db } from "../../../common/database";
import { RelationsList } from "../../../components/sheets/relations-list";
import ReminderSheet from "../../../components/sheets/reminder";
import useKeyboard from "../../../hooks/use-keyboard";
import { DDS } from "../../../services/device-detection";
import {
@@ -54,13 +53,15 @@ import {
eOpenPublishNoteDialog,
eOpenTagsDialog
} from "../../../utils/events";
import { openLinkInBrowser } from "../../../utils/functions";
import { tabBarRef } from "../../../utils/global-refs";
import { NoteType } from "../../../utils/types";
import { useDragState } from "../../settings/editor/state";
import { EventTypes } from "./editor-events";
import { EditorMessage, EditorProps, useEditorType } from "./types";
import { EditorEvents, editorState } from "./utils";
import { openLinkInBrowser } from "../../../utils/functions";
import { EventTypes } from "./editor-events";
import { RelationsList } from "../../../components/sheets/relations-list";
import ReminderSheet from "../../../components/sheets/reminder";
const publishNote = async (editor: useEditorType) => {
const user = useUserStore.getState().user;
@@ -362,6 +363,7 @@ export const useEditorEvents = (
if (editor.state.current?.isFocused) {
editor.state.current.isFocused = true;
}
umami.pageView("/pro-screen", "/editor");
eSendEvent(eOpenPremiumDialog);
break;
case EventTypes.monograph:

View File

@@ -112,7 +112,7 @@ export const useEditor = (
(show: boolean, data = { type: "new" }) => {
eSendEvent(
"loadingNote" + editorId,
show ? data || currentNote.current : false
show ? currentNote.current || data : false
);
},
[editorId]

View File

@@ -30,8 +30,6 @@ import SearchService from "../../services/search";
import SettingsService from "../../services/settings";
import useNavigationStore from "../../stores/use-navigation-store";
import { useNotebookStore } from "../../stores/use-notebook-store";
import { Config } from "react-native-config";
const onPressFloatingButton = () => {
AddNotebookEvent();
};
@@ -70,7 +68,7 @@ export const Notebooks = ({
SearchService.prepareSearch = prepareSearch;
useNavigationStore.getState().setButtonAction(onPressFloatingButton);
//@ts-ignore need to update typings in core to fix this
if (db.notebooks.all.length === 0 && !Config.isTesting) {
if (db.notebooks.all.length === 0) {
Walkthrough.present("notebooks");
} else {
Walkthrough.update("notebooks");

View File

@@ -31,14 +31,13 @@ import { TopicType } from "../../utils/types";
import { editorController, editorState } from "../editor/tiptap/utils";
export function toCamelCase(title: string) {
if (!title) return "";
return title.slice(0, 1).toUpperCase() + title.slice(1);
}
export function getAlias(params: Partial<NotesScreenParams>) {
if (!params) return "";
const { item } = params;
return (item as TopicType)?.alias || item?.title || "";
return (item as TopicType)?.alias || item?.title;
}
export function openMonographsWebpage() {

View File

@@ -21,6 +21,7 @@ import React, { useState } from "react";
import { Dimensions, LayoutAnimation, Platform, View } from "react-native";
import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import umami from "../../common/analytics";
import { SVG_Z } from "../../components/intro";
import { WelcomeNotice } from "../../components/intro/welcome";
import { Button } from "../../components/ui/button";
@@ -129,7 +130,7 @@ const AppLock = ({ route }) => {
<View
style={{
paddingHorizontal: 12,
width: DDS.isTab && welcome ? "50%" : "100%",
width: DDS.isTab && welcome ? "50%" : undefined,
alignSelf: "center"
}}
>
@@ -204,6 +205,7 @@ const AppLock = ({ route }) => {
type: "linear"
}
});
umami.pageView("/privacymode", "/welcome");
setStep(1);
}}
style={{

View File

@@ -22,7 +22,6 @@ import { AccentColorPicker, HomagePageSelector } from "./appearance";
import { AutomaticBackupsSelector } from "./backup-restore";
import DebugLogs from "./debug";
import { ConfigureToolbar } from "./editor/configure-toolbar";
import { Licenses } from "./licenses";
import SoundPicker from "./sound-picker";
import { Subscription } from "./subscription";
export const components: { [name: string]: ReactElement } = {
@@ -32,6 +31,5 @@ export const components: { [name: string]: ReactElement } = {
subscription: <Subscription />,
configuretoolbar: <ConfigureToolbar />,
"debug-logs": <DebugLogs />,
"sound-picker": <SoundPicker />,
licenses: <Licenses />
"sound-picker": <SoundPicker />
};

View File

@@ -1,466 +0,0 @@
/* eslint-disable header/header */
export const LICENSES = [
{
name: "@callstack/repack",
licenseType: "MIT",
author: "zamotany <zamotany.oss@gmail.com>",
link: "https://github.com/callstack/repack"
},
{
name: "@react-native-clipboard/clipboard",
licenseType: "MIT",
author: "M.Haris Baig <harisbaig100@gmail.com>",
link: "https://github.com/react-native-clipboard/clipboard"
},
{
name: "@react-native-community/checkbox",
licenseType: "MIT",
author: "Nicholas Lee <nicholaslee119@gmail.com>",
link: "https://github.com/react-native-community/react-native-checkbox"
},
{
name: "@react-native-community/netinfo",
licenseType: "MIT",
author: "Matt Oakes <hello@mattoakes.net>",
link: "https://github.com/react-native-netinfo/react-native-netinfo"
},
{
name: "@react-native-community/toolbar-android",
licenseType: "MIT",
author: "Connectdotz <vsun@connectdotz.com>",
link: "https://github.com/react-native-community/toolbar-android"
},
{
name: "@react-native-masked-view/masked-view",
licenseType: "MIT",
author: "Mike Nedosekin <crespo8800@gmail.com>",
link: "https://github.com/react-native-masked-view/masked-view"
},
{
name: "@react-navigation/elements",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/react-navigation/react-navigation"
},
{
name: "@react-navigation/native",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/react-navigation/react-navigation"
},
{
name: "@react-navigation/native-stack",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/react-navigation/react-navigation"
},
{
name: "@sayem314/react-native-keep-awake",
licenseType: "MIT",
author: "Sayem Chowdhury",
link: "https://github.com/sayem314/react-native-keep-awake"
},
{
name: "deprecated-react-native-prop-types",
licenseType: "MIT",
author: "n/a",
link: "git@github.com:facebookarchive/react-native-deprecated-modules"
},
{
name: "react",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/facebook/react"
},
{
name: "react-native",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/facebook/react-native"
},
{
name: "react-native-background-actions",
licenseType: "MIT",
author: "Rapsssito contact@rodrigomartin.dev",
link: "https://github.com/Rapsssito/react-native-background-actions"
},
{
name: "react-native-begin-background-task",
licenseType: "MIT",
author: "Ivan Zotov <github@ivanzotov.com>",
link: "n/a"
},
{
name: "react-native-bootsplash",
licenseType: "MIT",
author: "Mathieu Acthernoene <zoontek@gmail.com>",
link: "https://github.com/zoontek/react-native-bootsplash"
},
{
name: "react-native-config",
licenseType: "MIT",
author: "Pedro Belo",
link: "https://github.com/luggit/react-native-config"
},
{
name: "react-native-device-info",
licenseType: "MIT",
author:
"Rebecca Hughes <rebecca@learnium.net> (https://github.com/rebeccahughes)",
link: "https://github.com/react-native-device-info/react-native-device-info"
},
{
name: "react-native-document-picker",
licenseType: "MIT",
author:
"Elyx0 <elyx00@gmail.com> (https://github.com/rnmods), Vojtech Novak (hello@react-native-training.eu)",
link: "https://github.com/rnmods/react-native-document-picker"
},
{
name: "react-native-eventsource",
licenseType: "MIT",
author: "João Ribeiro jonnybgod@gmail.com",
link: "n/a"
},
{
name: "react-native-exit-app",
licenseType: "MIT",
author: "Wumke",
link: "n/a"
},
{
name: "react-native-file-viewer",
licenseType: "MIT",
author: "Vincenzo Scamporlino",
link: "git://github.com/vinzscam/react-native-file-viewer"
},
{
name: "react-native-fingerprint-scanner",
licenseType: "MIT",
author: "Hieu Van (https://github.com/hieuvp)",
link: "n/a"
},
{
name: "react-native-gesture-handler",
licenseType: "MIT",
author: "Krzysztof Magiera krzys.magiera@gmail.com",
link: "https://github.com/software-mansion/react-native-gesture-handler"
},
{
name: "react-native-get-random-values",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/LinusU/react-native-get-random-values"
},
{
name: "react-native-html-to-pdf-lite",
licenseType: "MIT",
author: "Oni Benjamin <onibenjo@gmail.com>",
link: "https://github.com/Onibenjo/react-native-html-to-pdf"
},
{
name: "react-native-iap",
licenseType: "MIT",
author: "dooboolab",
link: "https://github.com/dooboolab/react-native-iap"
},
{
name: "react-native-image-picker",
licenseType: "MIT",
author: "Johan du Toit (Johan-dutoit)",
link: "https://github.com/react-native-image-picker/react-native-image-picker"
},
{
name: "react-native-keychain",
licenseType: "MIT",
author: "Joel Arvidsson joel@oblador.se",
link: "git://github.com/oblador/react-native-keychain"
},
{
name: "react-native-mmkv-storage",
licenseType: "MIT",
author: "Ammar Ahmed for @ammarahm-ed",
link: "https://github.com/ammarahm-ed/react-native-mmkv-storage"
},
{
name: "react-native-orientation",
licenseType: "ISC",
author: "Yamill Vallecillo <yamill@gmail.com> (github.com/yamill)",
link: "n/a"
},
{
name: "react-native-privacy-snapshot",
licenseType: "MIT",
author: "Roger Chapman",
link: "n/a"
},
{
name: "react-native-reanimated",
licenseType: "MIT",
author: "Krzysztof Magiera krzys.magiera@gmail.com",
link: "https://github.com/software-mansion/react-native-reanimated"
},
{
name: "react-native-safe-area-context",
licenseType: "MIT",
author: "Janic Duplessis <janicduplessis@gmail.com>",
link: "https://github.com/th3rdwave/react-native-safe-area-context"
},
{
name: "react-native-scoped-storage",
licenseType: "MIT",
author: "Ammar Ahmed @ammarahm-ed",
link: "https://github.com/ammarahm-ed/react-native-scoped-storage"
},
{
name: "react-native-screens",
licenseType: "MIT",
author: "Krzysztof Magiera krzys.magiera@gmail.com",
link: "https://github.com/software-mansion/react-native-screens"
},
{
name: "react-native-securerandom",
licenseType: "MIT",
author: "Rob Hogan npm@rhogan.net https://github.com/robhogan",
link: "https://github.com/robhogan/react-native-securerandom"
},
{
name: "react-native-share",
licenseType: "MIT",
author: "Esteban Fuentealba efuentealba@json.cl",
link: "https://github.com/react-native-community/react-native-share"
},
{
name: "@ammarahmed/react-native-sodium",
licenseType: "n/a",
author: "n/a",
link: "https://github.com/lyubo/react-native-sodium"
},
{
name: "react-native-svg",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/react-native-community/react-native-svg"
},
{
name: "react-native-tooltips",
licenseType: "Apache License",
author: "Pranav Raj Singh Chauhan",
link: "https://github.com/prscX/react-native-tooltips"
},
{
name: "react-native-vector-icons",
licenseType: "MIT",
author: "Joel Arvidsson joel@oblador.se",
link: "git://github.com/oblador/react-native-vector-icons"
},
{
name: "react-native-webview",
licenseType: "MIT",
author: "Jamon Holmgren <jamon@infinite.red>",
link: "https://github.com/react-native-webview/react-native-webview"
},
{
name: "rn-extensions-share",
licenseType: "MIT",
author:
"Djorkaeff Alexandre djorkaeffalexandre@gmail.com http://github.com/djorkaeffalexandre",
link: "https://github.com/RocketChat/rn-extensions-share"
},
{
name: "rn-fetch-blob",
licenseType: "MIT",
author: "Joltup",
link: "https://github.com/joltup/rn-fetch-blob"
},
{
name: "react-native-gzip",
licenseType: "MIT",
author:
"ammarahm-ed <ammarahmed6506@gmail.com> (https://github.com/ammarahm-ed)",
link: "https://github.com/ammarahm-ed/react-native-gzip"
},
{
name: "@shopify/flash-list",
licenseType: "MIT",
author: "shopify",
link: "https://github.com/Shopify/flash-list"
},
{
name: "@notifee/react-native",
licenseType: "Apache-2.0",
author: "Invertase <oss@invertase.io> (http://invertase.io)",
link: "https://github.com/invertase/notifee"
},
{
name: "react-native-modal-datetime-picker",
licenseType: "MIT",
author: "Mazzarolo Matteo",
link: "https://github.com/mmazzarolo/react-native-modal-datetime-picker"
},
{
name: "@react-native-community/datetimepicker",
licenseType: "MIT",
author:
"Martijn Swaagman <mswaagman@godaddy.com> (https://github.com/swaagie)",
link: "https://github.com/react-native-community/datetimepicker"
},
{
name: "react-native-date-picker",
licenseType: "MIT",
author: "henninghall",
link: "ssh://git@github.com/henninghall/react-native-date-picker"
},
{
name: "react-native-notification-sounds",
licenseType: "MIT",
author: "Asad Iqbal asad.dsoft@gmail.com",
link: "https://github.com/saadqbal/react-native-notification-sounds"
},
{
name: "@flyerhq/react-native-link-preview",
licenseType: "MIT",
author: "Oleksandr Demchenko <alexdemchenko@yahoo.com>",
link: "https://github.com/flyerhq/react-native-link-preview#readme"
},
{
name: "@mdi/js",
licenseType: "Apache-2.0",
author: "Austin Andrews",
link: "https://github.com/Templarian/MaterialDesign-JS"
},
{
name: "absolutify",
licenseType: "MIT",
author:
"Beau Sorensen <mail@beausorensen.com> (http://github.com/sorensen)",
link: "git://github.com/sorensen/absolutify"
},
{
name: "buffer",
licenseType: "MIT",
author: "Feross Aboukhadijeh feross@feross.org https://feross.org",
link: "git://github.com/feross/buffer"
},
{
name: "dayjs",
licenseType: "MIT",
author: "iamkun",
link: "https://github.com/iamkun/dayjs"
},
{
name: "entities",
licenseType: "BSD-2-Clause",
author: "Felix Boehm <me@feedic.com>",
link: "git://github.com/fb55/entities"
},
{
name: "html-to-text",
licenseType: "MIT",
author: "Malte Legenhausen legenhausen@werk85.de",
link: "git://github.com/html-to-text/node-html-to-text"
},
{
name: "phone",
licenseType: "MIT",
author: "AfterShip",
link: "https://github.com/aftership/phone"
},
{
name: "qclone",
licenseType: "MIT",
author: "Yuriy Khomenko",
link: "https://github.com/Yuriy-Khomenko/qclone"
},
{
name: "react-native-actions-sheet",
licenseType: "MIT",
author: "ammarahm-ed",
link: "https://github.com/ammarahm-ed/react-native-actions-sheet"
},
{
name: "react-native-check-version",
licenseType: "MIT",
author: "Flexible Agency <info@flexible.agency>",
link: "n/a"
},
{
name: "react-native-drax",
licenseType: "MIT",
author: "Joe Lafiosca <joe@proxi.gg>",
link: "ssh://git@github.com/nuclearpasta/react-native-drax"
},
{
name: "react-native-image-zoom-viewer",
licenseType: "MIT",
author: "ascoders",
link: "https://github.com/ascoders/react-native-image-viewer"
},
{
name: "react-native-progress",
licenseType: "MIT",
author: "Joel Arvidsson joel@oblador.se",
link: "git://github.com/oblador/react-native-progress"
},
{
name: "react-native-qrcode-svg",
licenseType: "MIT",
author: "awesomejerry",
link: "ssh://git@github.com/awesomejerry/react-native-qrcode-svg"
},
{
name: "react-native-reanimated-material-menu",
licenseType: "MIT",
author:
"Maksim Milyutin <mmxckk@gmail.com> (https://github.com/mxck) & Ammar Ahmed <ammarahmed6506@gmail.com> (https://github.com/ammarahm-ed/)",
link: "n/a"
},
{
name: "react-native-reanimated-progress-bar",
licenseType: "MIT",
author: "Serhii Tanskiy",
link: "https://github.com/serzmerz/react-native-progress-bar"
},
{
name: "@streetwriters/showdown",
licenseType: "MIT",
author: "Estevão Santos",
link: "https://github.com/showdownjs/showdown"
},
{
name: "toggle-switch-react-native",
licenseType: "MIT",
author: "aminebenkeroum",
link: "https://github.com/aminebenkeroum/toggle-switch-react-native"
},
{
name: "url",
licenseType: "MIT",
author: "n/a",
link: "https://github.com/defunctzombie/node-url"
},
{
name: "validator",
licenseType: "MIT",
author: "Chris O'Hara <cohara87@gmail.com>",
link: "https://github.com/validatorjs/validator.js"
},
{
name: "zustand",
licenseType: "MIT",
author: "Paul Henschel",
link: "https://github.com/pmndrs/zustand"
},
{
name: "fflate",
licenseType: "MIT",
author: "Arjun Barrett <arjunbarrett@gmail.com>",
link: "https://github.com/101arrowz/fflate"
},
{
name: "timeago.js",
licenseType: "MIT",
author: "hustcc https://timeago.org",
link: "https://github.com/hustcc/timeago.js"
}
];

View File

@@ -1,71 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import { LICENSES } from "./license-data";
import { FlatList, Linking } from "react-native";
import { PressableButton } from "../../components/ui/pressable";
import Heading from "../../components/ui/typography/heading";
import { SIZE } from "../../utils/size";
import { useThemeStore } from "../../stores/use-theme-store";
import Paragraph from "../../components/ui/typography/paragraph";
type LicenseEntry = {
name: string;
licenseType: string;
author: string;
link: string;
};
export const Licenses = () => {
const colors = useThemeStore((state) => state.colors);
const renderItem = React.useCallback(
({ item }: { item: LicenseEntry }) => (
<PressableButton
key={item.name}
customStyle={{
alignItems: "flex-start",
justifyContent: "flex-start",
alignSelf: "flex-start",
padding: 12,
borderBottomWidth: 1,
borderBottomColor: colors.nav,
borderRadius: 0
}}
onPress={() => {
Linking.openURL(item.link).catch(console.log);
}}
>
<Heading size={SIZE.sm}>{item.name}</Heading>
<Paragraph>
{item.licenseType} | {item.author?.split("<")[0]}
</Paragraph>
</PressableButton>
),
[colors.nav]
);
return (
<FlatList
data={LICENSES}
style={{
width: "100%"
}}
renderItem={renderItem}
/>
);
};

View File

@@ -1088,14 +1088,6 @@ export const settingsGroups: SettingSection[] = [
}
},
description: "Read our privacy policy"
},
{
id: "licenses",
name: "Open source Licenses",
type: "screen",
component: "licenses",
description: "Open source libraries used in Notesnook",
icon: "open-source-initiative"
}
]
},

View File

@@ -16,108 +16,106 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import BackgroundFetch from "react-native-background-fetch";
import { DatabaseLogger, db } from "../common/database";
import { AppState, AppRegistry } from "react-native";
import Notifications from "./notifications";
import SettingsService from "./settings";
// import BackgroundFetch from "react-native-background-fetch";
// import { DatabaseLogger, db } from "../common/database";
// import { AppState, AppRegistry } from "react-native";
// import Notifications from "./notifications";
// import SettingsService from "./settings";
let backgroundFetchStarted = false;
async function start() {
if (backgroundFetchStarted) return;
backgroundFetchStarted = true;
// BackgroundFetch event handler.
const onEvent = async (taskId: string) => {
console.log("[BackgroundFetch] task: ", taskId, AppState.currentState);
// Do your background work...
await onBackgroundSyncStarted();
// IMPORTANT: You must signal to the OS that your task is complete.
BackgroundFetch.finish(taskId);
};
// let backgroundFetchStarted = false;
// async function start() {
// if (backgroundFetchStarted) return;
// backgroundFetchStarted = true;
// // BackgroundFetch event handler.
// const onEvent = async (taskId: string) => {
// console.log("[BackgroundFetch] task: ", taskId, AppState.currentState);
// // Do your background work...
// await onBackgroundSyncStarted();
// // IMPORTANT: You must signal to the OS that your task is complete.
// BackgroundFetch.finish(taskId);
// };
// Timeout callback is executed when your Task has exceeded its allowed running-time.
// You must stop what you're doing immediately BackgroundFetch.finish(taskId)
const onTimeout = async (taskId: string) => {
console.warn("[BackgroundFetch] TIMEOUT: ", taskId);
BackgroundFetch.finish(taskId);
};
// // Timeout callback is executed when your Task has exceeded its allowed running-time.
// // You must stop what you're doing immediately BackgroundFetch.finish(taskId)
// const onTimeout = async (taskId: string) => {
// console.warn("[BackgroundFetch] TIMEOUT: ", taskId);
// BackgroundFetch.finish(taskId);
// };
// Initialize BackgroundFetch only once when component mounts.
const status = await BackgroundFetch.configure(
{
minimumFetchInterval: 15,
enableHeadless: true,
startOnBoot: true,
stopOnTerminate: false,
requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY
},
onEvent,
onTimeout
);
DatabaseLogger.info(`[BackgroundFetch] configure status: ${status}`);
console.log(`[BackgroundFetch] configure status: ${status}`);
}
// // Initialize BackgroundFetch only once when component mounts.
// const status = await BackgroundFetch.configure(
// {
// minimumFetchInterval: 15,
// enableHeadless: true,
// startOnBoot: true,
// stopOnTerminate: false,
// requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY
// },
// onEvent,
// onTimeout
// );
// DatabaseLogger.info(`[BackgroundFetch] configure status: ${status}`);
// console.log(`[BackgroundFetch] configure status: ${status}`);
// }
const task = async (event: { taskId: string; timeout: boolean }) => {
// Get task id from event {}:
const taskId = event.taskId;
const isTimeout = event.timeout; // <-- true when your background-time has expired.
if (isTimeout) {
console.log("[BackgroundFetch] Headless TIMEOUT:", taskId);
BackgroundFetch.finish(taskId);
return;
}
console.log(
"[BackgroundFetch HeadlessTask] start: ",
taskId,
AppState.currentState
);
await onBackgroundSyncStarted();
BackgroundFetch.finish(taskId);
};
// const task = async (event: { taskId: string; timeout: boolean }) => {
// // Get task id from event {}:
// const taskId = event.taskId;
// const isTimeout = event.timeout; // <-- true when your background-time has expired.
// if (isTimeout) {
// console.log("[BackgroundFetch] Headless TIMEOUT:", taskId);
// BackgroundFetch.finish(taskId);
// return;
// }
// DatabaseLogger.info(
// "[BackgroundFetch HeadlessTask] start: " + taskId + AppState.currentState
// );
// await onBackgroundSyncStarted();
// BackgroundFetch.finish(taskId);
// };
BackgroundFetch.registerHeadlessTask(task);
// BackgroundFetch.registerHeadlessTask(task);
async function onBackgroundSyncStarted() {
try {
console.log("Background Sync", "start");
await db.init();
const user = await db.user?.getUser();
if (user) {
await db.sync(true, false);
}
await Notifications.setupReminders();
console.log("Background Sync", "end");
} catch (e) {
DatabaseLogger.error(e as Error);
console.log("Background Sync Error", (e as Error).message);
}
}
// async function onBackgroundSyncStarted() {
// try {
// DatabaseLogger.info("Background Sync" + "start");
// await db.init();
// const user = await db.user?.getUser();
// if (user) {
// await db.sync(true, false);
// }
// await Notifications.setupReminders();
// DatabaseLogger.info("Background Sync" + "end");
// } catch (e) {
// DatabaseLogger.error(e as Error);
// console.log("Background Sync Error", (e as Error).message);
// }
// }
const onBoot = async () => {
try {
console.log("BOOT TASK STARTED");
await db.init();
await Notifications.setupReminders();
SettingsService.init();
if (SettingsService.get().notifNotes) {
Notifications.pinQuickNote(false);
}
console.log("BOOT TASK COMPLETE");
} catch (e) {
console.log(e);
}
};
// const onBoot = async () => {
// try {
// DatabaseLogger.info("BOOT TASK STARTED");
// await db.init();
// await Notifications.setupReminders();
// SettingsService.init();
// if (SettingsService.get().notifNotes) {
// Notifications.pinQuickNote(false);
// }
// DatabaseLogger.info("BOOT TASK COMPLETE");
// } catch (e) {
// console.log(e);
// }
// };
AppRegistry.registerHeadlessTask(
"com.streetwriters.notesnook.BOOT_TASK",
() => {
return onBoot;
}
);
// const registerHeadlessTask = () =>
// AppRegistry.registerHeadlessTask(
// "com.streetwriters.notesnook.BOOT_TASK",
// () => {
// return onBoot;
// }
// );
// export const BackgroundSync = {
// start,
// registerHeadlessTask
// };
export {};
export const BackgroundSync = {
start
};

View File

@@ -17,8 +17,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Platform } from "react-native";
import { verifyUser } from "../screens/settings/functions";
import { useMessageStore } from "../stores/use-message-store";
import {
eOpenLoginDialog,
@@ -27,6 +25,9 @@ import {
} from "../utils/events";
import { eSendEvent } from "./event-manager";
import PremiumService from "./premium";
import { verifyUser } from "../screens/settings/functions";
import { Platform } from "react-native";
import umami from "../common/analytics";
import SettingsService from "./settings";
const rateAppMessage = {
@@ -81,6 +82,7 @@ const loginMessage = {
message: "You are not logged in",
actionText: "Login to encrypt and sync notes",
onPress: () => {
umami.pageView("/signup", "/welcome/home");
eSendEvent(eOpenLoginDialog);
},
data: {},

View File

@@ -41,10 +41,10 @@ import { DDS } from "./device-detection";
import { eSendEvent } from "./event-manager";
import SettingsService from "./settings";
import { useSettingStore } from "../stores/use-setting-store";
import ReminderNotify from "../components/sheets/reminder-notify";
import { sleep } from "../utils/time";
import { useRelationStore } from "../stores/use-relation-store";
import { useReminderStore } from "../stores/use-reminder-store";
import { presentDialog } from "../components/dialog/functions";
export type Reminder = {
id: string;
@@ -106,8 +106,6 @@ const onEvent = async ({ type, detail }: Event) => {
if (notification?.data?.type === "reminder") {
const reminder = db.reminders?.reminder(notification.id?.split("_")[0]);
await sleep(1000);
const ReminderNotify =
require("../components/sheets/reminder-notify").default;
ReminderNotify.present(reminder);
}
@@ -452,10 +450,6 @@ async function displayNotification({
localOnly: true,
channelId: await getChannelId("default"),
autoCancel: false,
pressAction: {
id: "default",
mainComponent: "notesnook"
},
actions: actions?.map((action) => ({
pressAction: {
id: action
@@ -483,30 +477,7 @@ async function displayNotification({
}
}
function openSettingsDialog(context: any) {
return new Promise((resolve) => {
presentDialog({
title: "Notifications disabled",
paragraph: `Reminders cannot be set because notifications have been disabled from app settings. If you want to keep receiving reminder notifications, enable notifications for Notesnook from app settings.`,
positiveText: Platform.OS === "ios" ? undefined : "Open settings",
negativeText: Platform.OS === "ios" ? "Close" : "Cancel",
positivePress:
Platform.OS === "ios"
? undefined
: () => {
resolve(true);
},
onClose: () => {
resolve(false);
},
context: context
});
});
}
async function checkAndRequestPermissions(
promptUser?: boolean
): Promise<boolean> {
async function checkAndRequestPermissions() {
let permissionStatus = await notifee.getNotificationSettings();
if (Platform.OS === "android") {
if (
@@ -521,28 +492,16 @@ async function checkAndRequestPermissions(
await notifee.openAlarmPermissionSettings();
}
permissionStatus = await notifee.getNotificationSettings();
if (
permissionStatus.authorizationStatus === AuthorizationStatus.AUTHORIZED &&
permissionStatus.android.alarm === 1
)
return true;
if (promptUser) {
if (await openSettingsDialog("local")) {
await notifee.openNotificationSettings();
return false;
}
}
return false;
} else {
permissionStatus = await notifee.requestPermission();
if (permissionStatus.authorizationStatus === AuthorizationStatus.AUTHORIZED)
return true;
if (promptUser) {
await openSettingsDialog("local");
}
return false;
}
}

View File

@@ -19,12 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { Dimensions, PlatformOSType } from "react-native";
import Config from "react-native-config";
import { Sound } from "react-native-notification-sounds";
import { initialWindowMetrics } from "react-native-safe-area-context";
import { FileType } from "react-native-scoped-storage";
import create, { State } from "zustand";
import { Reminder } from "../services/notifications";
import { ACCENT } from "../utils/color-scheme";
import { initialWindowMetrics } from "react-native-safe-area-context";
import { Reminder } from "../services/notifications";
import { Sound } from "react-native-notification-sounds";
export type Settings = {
showToolbarOnTop?: boolean;
@@ -123,7 +123,7 @@ export const useSettingStore = create<SettingStore>((set) => ({
screenshotMode: true,
privacyScreen: false,
appLockMode: "none",
telemetry: false,
telemetry: true,
notebooksListMode: "normal",
notesListMode: "normal",
devMode: false,

View File

@@ -25,18 +25,17 @@ import {
tapByText,
createNote,
prepare,
visibleById,
notVisibleById,
navigate,
elementByText,
sleep,
notVisibleByText
sleep
} from "./utils";
async function createNotebook(
title = "Notebook 1",
description = true,
topic = true,
topicCount = 1
topic = true
) {
await tapByText("Add your first notebook");
await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(
@@ -48,12 +47,10 @@ async function createNotebook(
).typeText(`Description of ${title}`);
}
if (topic) {
for (let i = 1; i <= topicCount; i++) {
await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
i === 1 ? "Topic" : "Topic " + i
);
await tapById("topic-add-button");
}
await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
"Topic"
);
await tapById("topic-add-button");
}
await tapByText("Create notebook");
await sleep(500);
@@ -70,7 +67,7 @@ describe("NOTEBOOKS", () => {
it("Create a notebook with title only", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -82,7 +79,7 @@ describe("NOTEBOOKS", () => {
it("Create a notebook title & description", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, false);
await sleep(500);
@@ -94,6 +91,7 @@ describe("NOTEBOOKS", () => {
it("Create a notebook with description and topics", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -106,6 +104,7 @@ describe("NOTEBOOKS", () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
@@ -122,6 +121,7 @@ describe("NOTEBOOKS", () => {
it("Add new topic to notebook", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, false);
await sleep(500);
@@ -138,6 +138,7 @@ describe("NOTEBOOKS", () => {
it("Edit topic", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
@@ -156,6 +157,7 @@ describe("NOTEBOOKS", () => {
it("Add new note to topic", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
@@ -168,6 +170,8 @@ describe("NOTEBOOKS", () => {
it("Remove note from topic", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
@@ -180,59 +184,31 @@ describe("NOTEBOOKS", () => {
await notVisibleById(note.title);
});
it.only("Add/Remove note to notebook from home", async () => {
it("Add/Remove note to notebook from home", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", true, true, 3);
await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
await sleep(500);
await navigate("Notes");
await createNote();
console.log("ADD TO A SINGLE TOPIC");
await tapById(notesnook.listitem.menu);
await tapById("icon-Add to notebook");
await sleep(500);
await tapByText("Notebook 1");
await tapByText("Topic");
await tapByText("Save");
await sleep(300);
await visibleByText("Notebook 1 Topic");
console.log("MOVE FROM ONE TOPIC TO ANOTHER");
await tapById(notesnook.listitem.menu);
await tapById("icon-Add to notebook");
await tapByText("Notebook 1");
await tapByText("Topic 2");
await tapByText("Save");
await visibleByText("Notebook 1 Topic 2");
console.log("REMOVE FROM TOPIC");
await tapById(notesnook.listitem.menu);
await tapById("icon-Add to notebook");
await tapByText("Notebook 1");
await tapByText("Topic 2");
await tapByText("Save");
await sleep(300);
await notVisibleByText("Notebook 1 Topic 2");
console.log("MOVE TO MULTIPLE TOPICS");
await tapById(notesnook.listitem.menu);
await tapById("icon-Add to notebook");
await tapByText("Notebook 1");
await elementByText("Topic").longPress();
await visibleByText("Reset selection");
await tapByText("Topic 2");
await tapByText("Topic 3");
await tapByText("Save");
await sleep(300);
await tapById(notesnook.listitem.menu);
await visibleByText("Topic");
await visibleByText("Topic 2");
await visibleByText("Topic 3");
await visibleById("icon-check");
await tapByText("Topic");
await notVisibleById("icon-check");
});
it("Edit notebook title, description and add a topic", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook();
await sleep(500);
@@ -265,7 +241,7 @@ describe("NOTEBOOKS", () => {
it("Move notebook to trash", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -285,7 +261,7 @@ describe("NOTEBOOKS", () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, true);
await sleep(500);
@@ -308,7 +284,7 @@ describe("NOTEBOOKS", () => {
await prepare();
let note = await createNote();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, true);
await sleep(500);
@@ -330,7 +306,7 @@ describe("NOTEBOOKS", () => {
it("Pin notebook to side menu", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1", false, false);
await sleep(500);
@@ -347,7 +323,7 @@ describe("NOTEBOOKS", () => {
it("Pin topic to side menu", async () => {
await prepare();
await navigate("Notebooks");
await tapByText("Skip introduction");
await sleep(500);
await createNotebook("Notebook 1");
await sleep(500);

View File

@@ -139,11 +139,6 @@ def reactNativeArchitectures() {
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}
def fdroidBuild() {
def value = project.getProperties().get("fdroidBuild")
return value ? value : false
}
def getNpmVersion() {
def inputFile = file("$rootDir/../../package.json")
def jsonPackage = new JsonSlurper().parseText(inputFile.text)
@@ -165,7 +160,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 2027
versionCode 2023
versionName getNpmVersion()
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
@@ -285,21 +280,18 @@ android {
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
if (fdroidBuild()) {
output.versionCodeOverride =
defaultConfig.versionCode * 5 + versionCodes.get(abi)
println("Fdroid Version code: ${output.versionCodeOverride} for abi ${versionCodes.get(abi)}");
} else {
println("Version code: ${output.versionCodeOverride} for abi ${versionCodes.get(abi)}");
output.versionCodeOverride =
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
}
dependencies {

View File

@@ -152,12 +152,12 @@
android:resource="@xml/file_viewer_provider_paths" />
</provider>
<!-- <receiver android:exported="true" android:name=".BootRecieverService" >-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />-->
<!-- <action android:name="android.intent.action.QUICKBOOT_POWERON" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
<receiver android:exported="true" android:name=".BootRecieverService" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>

View File

@@ -8,7 +8,7 @@ import javax.annotation.Nullable;
public class BootTaskService extends HeadlessJsTaskService {
@Override
@Override
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
return new HeadlessJsTaskConfig(
"com.streetwriters.notesnook.BOOT_TASK",

View File

@@ -69,8 +69,8 @@ allprojects {
maven { url 'https://www.jitpack.io' }
// maven {
// url("${project(':react-native-background-fetch').projectDir}/libs")
// }
maven {
url("${project(':react-native-background-fetch').projectDir}/libs")
}
}
}

View File

@@ -42,7 +42,4 @@ newArchEnabled=false
# V8 Cache Mode Config
# v8.cacheMode=none
# v8.android.tools.dir=/home/ammarahm-ed/Repos/notesnook-mobile/node_modules/v8-android-jit-nointl/dist/tools/android
# fdroid
fdroidBuild=false
# v8.android.tools.dir=/home/ammarahm-ed/Repos/notesnook-mobile/node_modules/v8-android-jit-nointl/dist/tools/android

View File

@@ -1,9 +1,8 @@
- Improved UX for linking Notebooks
- Redesign properties sheet to be simple & handy
- Added support for RTL languages in editor
- Telemetery is now opt-in
- Get default reminder title/description from note
- Fix unable to input recovery code on 2FA sheet
- Bug fixes & small improvements
- Cross platform Reminders 🔔
- Multi-factor auth is enabled by default for all users to improve login security
- Now you can change account email from Settings -> Account Settings -> Change email
- Added options to disable sync, auto-sync & real-time sync from settings.
- Improved PDF exports styling
- Many bug fixes and improvements
Thank you for using Notesnook!

View File

@@ -1,6 +1,60 @@
/* eslint-disable @typescript-eslint/no-var-requires */
global.Buffer = require('buffer').Buffer;
//import { ScriptManager, Script } from '@callstack/repack/client';
import '../app/common/logger/index';
import { DOMParser } from './worker.js';
// class DOM {
// static domparser;
// parseFromString(markupLanguage, mimeType, globals) {
// return DOM.domparser?.parseFromString(markupLanguage, mimeType, globals);
// }
// static async prepare() {
// if (!DOM.domparser) {
// let module = await import('./worker.js');
// DOM.domparser = new module.DOMParser();
// }
// }
// }
global.DOMParser = DOMParser;
// try {
// const shared = ScriptManager.shared;
// } catch (e) {
// new ScriptManager({
// resolve: async (scriptId, caller) => {
// if (__DEV__) {
// return {
// url: Script.getDevServerURL(scriptId),
// cache: false
// };
// }
// return {
// url: Script.getFileSystemURL(scriptId)
// };
// }
// });
// }
if (__DEV__) {
// ScriptManager.shared.on('resolving', (...args) => {
// console.log('DEBUG/resolving', ...args);
// });
// ScriptManager.shared.on('resolved', (...args) => {
// console.log('DEBUG/resolved', ...args);
// });
// ScriptManager.shared.on('prefetching', (...args) => {
// console.log('DEBUG/prefetching', ...args);
// });
// ScriptManager.shared.on('loading', (...args) => {
// console.log('DEBUG/loading', ...args);
// });
// ScriptManager.shared.on('loaded', (...args) => {
// console.log('DEBUG/loaded', ...args);
// });
// ScriptManager.shared.on('error', (...args) => {
// console.log('DEBUG/error', ...args);
// });
}

View File

@@ -1,13 +1,14 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import './globals.js';
import 'react-native-get-random-values';
import 'react-native-gesture-handler';
import React from 'react';
import { AppRegistry, LogBox, Platform, UIManager } from 'react-native';
import Config from 'react-native-config';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import appJson from './app.json';
import Notifications from "../app/services/notifications";
Notifications.init();
import Notifications from '../app/services/notifications';
import {BackgroundSync} from '../app/services/background-sync';
const appName = appJson.name;
if (Config.isTesting) {
@@ -21,7 +22,8 @@ if (__DEV__) {
LogBox.ignoreAllLogs();
}
let NotesnookShare;
BackgroundSync.start();
Notifications.init();
let QuickNoteIOS;
const AppProvider = () => {

View File

@@ -29,6 +29,7 @@
65AA857E25E6DDEC00772A01 /* NotesWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AA857D25E6DDEC00772A01 /* NotesWidget.swift */; };
65AA858025E6DDEE00772A01 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 65AA857F25E6DDEE00772A01 /* Assets.xcassets */; };
65AA858425E6DDEE00772A01 /* NotesWidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65AA857725E6DDEC00772A01 /* NotesWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
65B450AD2976AF0C00EA090B /* RNBackgroundFetch+AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 65B450AC2976AF0B00EA090B /* RNBackgroundFetch+AppDelegate.m */; };
65B5014425A672B200E2D264 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 65B5014325A672B200E2D264 /* ShareViewController.m */; };
65B5014725A672B200E2D264 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65B5014525A672B200E2D264 /* MainInterface.storyboard */; };
65B5014B25A672B200E2D264 /* Make Note.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65B5014025A672B200E2D264 /* Make Note.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -122,6 +123,7 @@
65AA857D25E6DDEC00772A01 /* NotesWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotesWidget.swift; sourceTree = "<group>"; };
65AA857F25E6DDEE00772A01 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
65AA858125E6DDEE00772A01 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
65B450AC2976AF0B00EA090B /* RNBackgroundFetch+AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "RNBackgroundFetch+AppDelegate.m"; path = "../../node_modules/react-native-background-fetch/ios/RNBackgroundFetch/RNBackgroundFetch+AppDelegate.m"; sourceTree = "<group>"; };
65B5014025A672B200E2D264 /* Make Note.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Make Note.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
65B5014325A672B200E2D264 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = "<group>"; };
65B5014625A672B200E2D264 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
@@ -221,6 +223,7 @@
13B07FAE1A68108700A75B9A /* Notesnook */ = {
isa = PBXGroup;
children = (
65B450AC2976AF0B00EA090B /* RNBackgroundFetch+AppDelegate.m */,
6593E4A2281C345400492C50 /* AppDelegate.mm */,
6529A13D279BC4C70048D4A8 /* BootSplash.storyboard */,
659BE46625E11A5100E05671 /* notesnook-text.png */,
@@ -941,6 +944,7 @@
65E0340B257B9FF100793428 /* File.swift in Sources */,
6593E4A3281C345400492C50 /* AppDelegate.mm in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
65B450AD2976AF0C00EA090B /* RNBackgroundFetch+AppDelegate.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1083,7 +1087,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2027;
CURRENT_PROJECT_VERSION = 2023;
DEVELOPMENT_TEAM = 53CWBG3QUC;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -1157,7 +1161,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.4.4;
MARKETING_VERSION = 2.4.0;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@@ -1187,7 +1191,7 @@
CODE_SIGN_ENTITLEMENTS = Notesnook/Notesnook.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2027;
CURRENT_PROJECT_VERSION = 2023;
DEVELOPMENT_TEAM = 53CWBG3QUC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@@ -1260,7 +1264,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.4.4;
MARKETING_VERSION = 2.4.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = (
"$(inherited)",
@@ -1418,7 +1422,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2027;
CURRENT_PROJECT_VERSION = 2023;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 53CWBG3QUC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -1430,7 +1434,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.4.4;
MARKETING_VERSION = 2.4.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.notewidget;
@@ -1460,7 +1464,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2027;
CURRENT_PROJECT_VERSION = 2023;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 53CWBG3QUC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -1472,7 +1476,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.4.4;
MARKETING_VERSION = 2.4.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.notewidget;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1501,7 +1505,7 @@
CODE_SIGN_ENTITLEMENTS = "Make Note/Make Note.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2027;
CURRENT_PROJECT_VERSION = 2023;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 53CWBG3QUC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -1575,7 +1579,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.4.4;
MARKETING_VERSION = 2.4.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.share;
@@ -1605,7 +1609,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2027;
CURRENT_PROJECT_VERSION = 2023;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 53CWBG3QUC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -1679,7 +1683,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.4.4;
MARKETING_VERSION = 2.4.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.share;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -7,7 +7,7 @@
#import <React/RCTAppSetupUtils.h>
#import <React/RCTLinkingManager.h>
#import "RNShortcuts.h"
//#import <TSBackgroundFetch/TSBackgroundFetch.h>
#import <TSBackgroundFetch/TSBackgroundFetch.h>
#if RCT_NEW_ARCH_ENABLED
#import <React/CoreModulesPlugins.h>
@@ -63,7 +63,7 @@ RCTBridge *bridge;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
//[[TSBackgroundFetch sharedInstance] didFinishLaunching];
[[TSBackgroundFetch sharedInstance] didFinishLaunching];
return YES;
}

View File

@@ -345,6 +345,8 @@ PODS:
- React-Core
- rn-fetch-blob (0.12.0):
- React-Core
- RNBackgroundFetch (4.1.7):
- React-Core
- RNBootSplash (4.3.2):
- React-Core
- RNCCheckbox (0.5.12):
@@ -369,10 +371,10 @@ PODS:
- React-Core
- RNKeychain (4.0.5):
- React
- RNNotifee (7.4.3):
- RNNotifee (7.3.1):
- React-Core
- RNNotifee/NotifeeCore (= 7.4.3)
- RNNotifee/NotifeeCore (7.4.3):
- RNNotifee/NotifeeCore (= 7.3.1)
- RNNotifee/NotifeeCore (7.3.1):
- React-Core
- RNPrivacySnapshot (1.0.0):
- React-Core
@@ -481,6 +483,7 @@ DEPENDENCIES:
- ReactCommon/turbomodule/core (from `../../node_modules/react-native/ReactCommon`)
- rn-extensions-share (from `../../node_modules/rn-extensions-share`)
- rn-fetch-blob (from `../../node_modules/rn-fetch-blob`)
- RNBackgroundFetch (from `../../node_modules/react-native-background-fetch`)
- RNBootSplash (from `../../node_modules/react-native-bootsplash`)
- "RNCCheckbox (from `../../node_modules/@react-native-community/checkbox`)"
- "RNCClipboard (from `../../node_modules/@react-native-clipboard/clipboard`)"
@@ -622,6 +625,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/rn-extensions-share"
rn-fetch-blob:
:path: "../../node_modules/rn-fetch-blob"
RNBackgroundFetch:
:path: "../../node_modules/react-native-background-fetch"
RNBootSplash:
:path: "../../node_modules/react-native-bootsplash"
RNCCheckbox:
@@ -736,6 +741,7 @@ SPEC CHECKSUMS:
ReactCommon: 1e783348b9aa73ae68236271df972ba898560a95
rn-extensions-share: 3f0ecce20dfbca1f0358deb4ebfb9ee121a6d92a
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
RNBackgroundFetch: 13fbe7b23d4a082eac8caa7b08c5bcbeabd92f79
RNBootSplash: 5f346163977573d6b2aeba1b25df9d2245c0d73c
RNCCheckbox: ed1b4ca295475b41e7251ebae046360a703b6eb5
RNCClipboard: 2834e1c4af68697089cdd455ee4a4cdd198fa7dd
@@ -748,7 +754,7 @@ SPEC CHECKSUMS:
RNGestureHandler: b7a872907ee289ada902127f2554fa1d2c076122
RNIap: d248609d1b8937e63bd904e865c318e9b1457eff
RNKeychain: 840f8e6f13be0576202aefcdffd26a4f54bfe7b5
RNNotifee: 5dfb0c5783ddb3da47b39e75d06cc7e748d6ca39
RNNotifee: 2fab820e17613db15a1f836053ee3b87af7e96b9
RNPrivacySnapshot: 8eaf571478a353f2e5184f5c803164f22428b023
RNReanimated: f1b109fb8341505ace9d7d2eedd150da1686716b
RNScreens: 34cc502acf1b916c582c60003dc3089fa01dc66d

View File

@@ -52,11 +52,12 @@
"rn-fetch-blob": "^0.12.0",
"react-native-gzip":"1.0.0",
"@shopify/flash-list":"1.4.0",
"@ammarahmed/notifee-react-native": "7.4.3",
"@ammarahmed/notifee-react-native": "7.3.1",
"react-native-modal-datetime-picker":"14.0.0",
"@react-native-community/datetimepicker":"6.6.0",
"react-native-date-picker": "4.2.6",
"react-native-notification-sounds": "0.5.5"
"react-native-notification-sounds": "0.5.5",
"react-native-background-fetch": "4.1.7"
},
"devDependencies": {
"@babel/core": "^7.12.9",

View File

@@ -1,5 +1,5 @@
const isGithubRelease = false;
const isGithubRelease = process.env.GITHUB_RELEASE;
const config = {
commands: require('@callstack/repack/commands'),
project: {

View File

@@ -1,9 +1,8 @@
- Improved UX for linking Notebooks
- Redesign properties sheet to be simple & handy
- Added support for RTL languages in editor
- Telemetery is now opt-in
- Get default reminder title/description from note
- Fix unable to input recovery code on 2FA sheet
- Bug fixes & small improvements
- Cross platform Reminders 🔔
- Multi-factor auth is enabled by default for all users to improve login security
- Now you can change account email from Settings -> Account Settings -> Change email
- Added options to disable sync, auto-sync & real-time sync from settings.
- Improved PDF exports styling
- Many bug fixes and improvements
Thank you for using Notesnook!

View File

@@ -1,12 +1,12 @@
{
"name": "@notesnook/mobile",
"version": "2.4.4",
"version": "2.4.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@notesnook/mobile",
"version": "2.4.4",
"version": "2.4.0",
"license": "GPL-3.0-or-later",
"workspaces": [
"native/",
@@ -60,7 +60,7 @@
"version": "1.0.0",
"license": "GPL-3.0-or-later",
"dependencies": {
"@ammarahmed/notifee-react-native": "7.4.3",
"@ammarahmed/notifee-react-native": "7.3.1",
"@ammarahmed/react-native-sodium": "1.2.0",
"@callstack/repack": "^3.0.0",
"@react-native-clipboard/clipboard": "^1.9.0",
@@ -78,6 +78,7 @@
"react": "18.0.0",
"react-native": "0.69.7",
"react-native-background-actions": "^2.6.6",
"react-native-background-fetch": "4.1.7",
"react-native-begin-background-task": "https://github.com/blockfirm/react-native-begin-background-task.git",
"react-native-bootsplash": "^4.1.4",
"react-native-config": "^1.4.6",
@@ -154,9 +155,9 @@
}
},
"node_modules/@ammarahmed/notifee-react-native": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.4.3.tgz",
"integrity": "sha512-7jz91BZLxsz3v2nOPSnUf0ULa/k+KtkyX8zN2ijeluLHSQ5fjSd5jQ+u+4+Rcja0g0xQze7fpg26q6lA6F2j1g==",
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.3.1.tgz",
"integrity": "sha512-kzBDw2NAt9kGD0CJ193JME4bS4uQolY+UubGiTnJwHfaLH7dFNju6RC15/u8tzG59ebDuCalkMLr+rAONtg2Rw==",
"peerDependencies": {
"react-native": "*"
}
@@ -17976,6 +17977,11 @@
"react-native": ">=0.47.0"
}
},
"node_modules/react-native-background-fetch": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/react-native-background-fetch/-/react-native-background-fetch-4.1.7.tgz",
"integrity": "sha512-dFY/AOZbEH+ldwZvq/UhhWI5+dyBYL1Xo5wqy6u5DLH+ef8jLIrwKQRmfLAWiP5BtZe6ktA55HM19X39qHoKEQ=="
},
"node_modules/react-native-begin-background-task": {
"version": "0.1.0",
"resolved": "git+ssh://git@github.com/blockfirm/react-native-begin-background-task.git#c2aa793249db6cc6298a812905f955a99b864e78",
@@ -21510,9 +21516,9 @@
},
"dependencies": {
"@ammarahmed/notifee-react-native": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.4.3.tgz",
"integrity": "sha512-7jz91BZLxsz3v2nOPSnUf0ULa/k+KtkyX8zN2ijeluLHSQ5fjSd5jQ+u+4+Rcja0g0xQze7fpg26q6lA6F2j1g=="
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/@ammarahmed/notifee-react-native/-/notifee-react-native-7.3.1.tgz",
"integrity": "sha512-kzBDw2NAt9kGD0CJ193JME4bS4uQolY+UubGiTnJwHfaLH7dFNju6RC15/u8tzG59ebDuCalkMLr+rAONtg2Rw=="
},
"@ammarahmed/react-native-sodium": {
"version": "1.2.0",
@@ -24310,7 +24316,7 @@
"@notesnook/mobile-native": {
"version": "file:native",
"requires": {
"@ammarahmed/notifee-react-native": "7.4.3",
"@ammarahmed/notifee-react-native": "7.3.1",
"@ammarahmed/react-native-sodium": "1.2.0",
"@babel/core": "^7.12.9",
"@babel/eslint-parser": "^7.16.5",
@@ -24359,6 +24365,7 @@
"react-native": "0.69.7",
"react-native-actions-shortcuts": "^1.0.1",
"react-native-background-actions": "^2.6.6",
"react-native-background-fetch": "4.1.7",
"react-native-begin-background-task": "https://github.com/blockfirm/react-native-begin-background-task.git",
"react-native-bootsplash": "^4.1.4",
"react-native-bundle-visualizer": "^3.1.1",
@@ -34852,6 +34859,11 @@
"eventemitter3": "^4.0.7"
}
},
"react-native-background-fetch": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/react-native-background-fetch/-/react-native-background-fetch-4.1.7.tgz",
"integrity": "sha512-dFY/AOZbEH+ldwZvq/UhhWI5+dyBYL1Xo5wqy6u5DLH+ef8jLIrwKQRmfLAWiP5BtZe6ktA55HM19X39qHoKEQ=="
},
"react-native-begin-background-task": {
"version": "git+ssh://git@github.com/blockfirm/react-native-begin-background-task.git#c2aa793249db6cc6298a812905f955a99b864e78",
"from": "react-native-begin-background-task@https://github.com/blockfirm/react-native-begin-background-task.git"

View File

@@ -1,6 +1,6 @@
{
"name": "@notesnook/mobile",
"version": "2.4.4",
"version": "2.4.0",
"private": true,
"license": "GPL-3.0-or-later",
"workspaces": [

View File

@@ -1,21 +0,0 @@
diff --git a/node_modules/react-native-actions-sheet/dist/src/index.js b/node_modules/react-native-actions-sheet/dist/src/index.js
index 7eb4357..18bf26d 100644
--- a/node_modules/react-native-actions-sheet/dist/src/index.js
+++ b/node_modules/react-native-actions-sheet/dist/src/index.js
@@ -747,7 +747,7 @@ var ActionSheet = /** @class */ (function (_super) {
width: "100%"
},
]}>
- {this.props.ExtraOverlayComponent}
+
<FlatList testID={(_a = this.props.testIDs) === null || _a === void 0 ? void 0 : _a.scrollview} bounces={false} keyboardShouldPersistTaps={keyboardShouldPersistTaps} keyboardDismissMode={keyboardDismissMode} ref={this.scrollViewRef} scrollEventThrottle={16} overScrollMode="never" showsVerticalScrollIndicator={false} onMomentumScrollBegin={this._onScrollBegin} onScrollEndDrag={this._onScrollEnd} onMomentumScrollEnd={this._onScrollEnd} scrollEnabled={scrollable} onScrollBeginDrag={this._onScrollBeginDrag} onTouchEnd={this._onTouchEnd} onScroll={this._onScroll} scrollsToTop={false} style={[
styles.scrollView,
@@ -821,6 +821,7 @@ var ActionSheet = /** @class */ (function (_super) {
</Animated.View>
</View>);
}}/>
+ {this.props.ExtraOverlayComponent}
</Animated.View>
</Root>
</>);

View File

@@ -7,21 +7,14 @@
{
"type": "chrome",
"request": "launch",
"preLaunchTask": "Start Notesnook (web)",
"preLaunchTask": "StartReactApp",
"postDebugTask": "Terminate All Tasks",
"name": "Debug Chrome",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"preLaunchTask": "Start Notesnook (web)",
"postDebugTask": "Terminate All Tasks",
"name": "Debug Firefox",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
"webRoot": "${workspaceFolder}",
"env": { "DISPLAY": ":0" },
"runtimeExecutable": "/usr/bin/brave-browser",
"runtimeArgs": ["--remote-debugging-port=9222"]
}
]
}

View File

@@ -5,26 +5,24 @@
"tasks": [
{
"type": "shell",
"command": "npm run debug",
"command": "yarn debug",
"group": {
"kind": "build",
"kind": "test",
"isDefault": true
},
"dependsOn": "Terminate All Tasks",
"isBackground": true, //This prevents the launch.json to wait for the completion of the task
"problemMatcher": {
"fileLocation": "relative",
"owner": "custom", //This is not needed but, required by the problemMatcher Object
"pattern": {
"regexp": "^$" //This is not needed but, required by the problemMatcher Object
},
"background": {
"activeOnStart": true,
"beginsPattern": "^$",
"endsPattern": "^You can now view (.*) in the browser.$"
"beginsPattern": "Compiling...", //Signals the begin of the Task
"endsPattern": "Compiled .*" //Signals that now the initialization of the task is complete
}
},
"label": "Start Notesnook (web)"
"label": "StartReactApp"
},
{
"label": "Terminate All Tasks",

View File

@@ -40,7 +40,7 @@ test.afterAll(async () => {
});
test.afterEach(async () => {
await app.goto(true);
await app.goto();
});
function roundOffPrices(prices: PriceItem[]) {
@@ -142,7 +142,7 @@ test("apply coupon through url", async () => {
planPrices[plan] = roundOffPrices(await pricing.getPrices());
await app.goto(true);
await app.goto();
}
for (const key in planPrices) {

View File

@@ -289,7 +289,9 @@ test("Ctrl+Click to select/unselect notes", async ({ page }, info) => {
}
await selectedNote.contextMenu.open();
expect(await selectedNote.contextMenu.title()).toBeFalsy();
expect(
(await selectedNote.contextMenu.title()) === (await selectedNote.getTitle())
).toBeTruthy();
});
test("opening a note & right clicking on another note should show note properties menu", async ({
@@ -304,5 +306,7 @@ test("opening a note & right clicking on another note should show note propertie
await notesList[0].click();
await selectedNote.contextMenu.open();
expect(await selectedNote.contextMenu.title()).toBeFalsy();
expect(
(await selectedNote.contextMenu.title()) === (await selectedNote.getTitle())
).toBeTruthy();
});

View File

@@ -48,10 +48,9 @@ export class AppModel {
this.routeHeader = this.page.locator(getTestId("routeHeader"));
}
async goto(isLoggedIn = false) {
async goto() {
await this.page.goto("/");
await this.routeHeader.waitFor({ state: "visible" });
if (!isLoggedIn) await this.navigation.waitForItem("Login");
}
goBack() {
@@ -102,9 +101,7 @@ export class AppModel {
async navigateTo(title: string) {
if ((await this.getRouteHeader()) === title) return;
const item = await this.navigation.findItem(title);
if (!item) throw new Error(`Could not find item to navigate to: ${title}`);
await item.click();
await item?.click();
await this.page.waitForTimeout(1000);
}

View File

@@ -21,15 +21,12 @@ import { Page, Locator } from "@playwright/test";
import { getTestId } from "../utils";
export class ContextMenuModel {
readonly menuContainer: Locator;
readonly titleText: Locator;
constructor(private readonly page: Page) {
this.menuContainer = this.page.locator(getTestId(`menu-container`));
this.titleText = this.page.locator(getTestId(`menu-title`));
}
async title() {
if (!(await this.titleText.isVisible())) return null;
return await this.titleText.textContent();
}
@@ -38,7 +35,7 @@ export class ContextMenuModel {
button: "left" | "right" | "middle" | undefined = "right"
) {
await locator.click({ button });
await this.menuContainer.waitFor();
await this.titleText.waitFor();
}
async clickOnItem(id: string) {

View File

@@ -38,12 +38,6 @@ export class NavigationMenuModel {
}
}
waitForItem(title: string) {
return this.menu
.locator(getTestId(`navigation-item`), { hasText: title })
.waitFor();
}
async getShortcuts() {
const shortcuts: string[] = [];
for await (const item of this.iterateList()) {
@@ -63,12 +57,13 @@ export class NavigationMenuModel {
}
class NavigationItemModel {
// private readonly title: Locator;
private readonly title: Locator;
private readonly shortcut: Locator;
private readonly menu: ContextMenuModel;
private readonly page: Page;
constructor(private readonly locator: Locator) {
this.page = locator.page();
this.title = locator.locator(getTestId("title"));
this.shortcut = locator.locator(getTestId("shortcut"));
this.menu = new ContextMenuModel(this.page);
}
@@ -82,7 +77,7 @@ class NavigationItemModel {
}
async getTitle() {
return await this.locator.getAttribute("title");
return await this.title.textContent();
}
async renameColor(alias: string) {

View File

@@ -250,9 +250,7 @@ export class NoteContextMenuModel extends BaseProperties {
async addToNotebook(notebook: Notebook) {
await this.open();
await this.menu.clickOnItem("notebooks");
await this.menu.clickOnItem("link-notebooks");
await this.menu.clickOnItem("addtonotebook");
const filterInput = this.page.locator(getTestId("filter-input"));
await filterInput.type(notebook.title);
@@ -265,15 +263,14 @@ export class NoteContextMenuModel extends BaseProperties {
const notebookItems = this.page.locator(getTestId("notebook"));
for await (const item of iterateList(notebookItems)) {
await item.locator(getTestId("notebook-tools")).click();
const title = item.locator(getTestId("notebook-title"));
const createTopicButton = item.locator(getTestId("create-topic"));
const notebookTitle = await title.textContent();
const treeItem = item.locator(getTestId(`tree-item`));
const title = treeItem.locator(getTestId("title"));
const newItemButton = treeItem.locator(getTestId("tree-item-new"));
if (notebookTitle?.includes(notebook.title)) {
if ((await title.textContent()) === notebook.title) {
for (const topic of notebook.topics) {
await createTopicButton.click();
const newItemInput = item.locator(getTestId("new-topic-input"));
await newItemButton.click();
const newItemInput = item.locator(getTestId("new-tree-item-input"));
await newItemInput.waitFor({ state: "visible" });
await newItemInput.fill(topic);
@@ -284,9 +281,8 @@ export class NoteContextMenuModel extends BaseProperties {
const topicItems = item.locator(getTestId("topic"));
for await (const topicItem of iterateList(topicItems)) {
await this.page.keyboard.down("Control");
await topicItem.click();
await this.page.keyboard.up("Control");
const treeItem = topicItem.locator(getTestId(`tree-item`));
await treeItem.click();
}
}
}

View File

@@ -22,7 +22,7 @@ import { Locator } from "@playwright/test";
import { getTestId } from "../utils";
import { BaseItemModel } from "./base-item.model";
import { ContextMenuModel } from "./context-menu.model";
import { confirmDialog, fillReminderDialog } from "./utils";
import { fillReminderDialog } from "./utils";
export class ReminderItemModel extends BaseItemModel {
private readonly contextMenu: ContextMenuModel;
@@ -47,7 +47,6 @@ export class ReminderItemModel extends BaseItemModel {
await this.contextMenu.open(this.locator);
await this.contextMenu.clickOnItem("delete");
await confirmDialog(this.page);
await this.waitFor("detached");
}

View File

@@ -38,10 +38,6 @@ export class RemindersViewModel extends BaseViewModel {
await this.createButton.click();
await fillReminderDialog(this.page, reminder);
}
async createReminderAndWait(reminder: Partial<Reminder>) {
await this.createReminder(reminder);
if (reminder.title) await this.waitForItem(reminder.title);
return await this.findReminder(reminder);

View File

@@ -22,6 +22,7 @@ import { getTestId } from "../utils";
export class ToastsModel {
private readonly toasts: Locator;
private readonly toastMessage: Locator;
constructor(page: Page) {
this.toasts = page.locator(".toasts-container > div");

View File

@@ -95,11 +95,7 @@ test("add a note to notebook", async ({ page }) => {
topics: ["Hello", "World", "Did", "what"]
});
expect(
await app.toasts.waitForToast(
"1 note added to 4 topics & removed from 0 topics."
)
).toBe(true);
expect(await app.toasts.waitForToast("Added 1 note to 4 topics")).toBe(true);
});
const actors = ["contextMenu", "properties"] as const;

View File

@@ -182,6 +182,6 @@
</head>
<body>
<h1>Test 1</h1>
<p data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
<p dir="ltr" data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
</body>
</html>

View File

@@ -11,7 +11,7 @@
</head>
<body>
<h1>Test 1</h1>
<p data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
<p dir="ltr" data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
<br/>
Created on: <b>xxx</b><br/>
Edited on: <b>xxx</b>

View File

@@ -11,7 +11,7 @@
</head>
<body>
<h1>Test 1</h1>
<p data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
<p dir="ltr" data-spacing="double">This is Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1Test 1</p>
<br/>
Created on: <b>xxx</b><br/>
Edited on: <b>xxx</b>

View File

@@ -36,7 +36,7 @@ test("add a one-time reminder", async ({ page }, info) => {
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait(ONE_TIME_REMINDER);
const reminder = await reminders.createReminder(ONE_TIME_REMINDER);
expect(reminder).toBeDefined();
@@ -44,34 +44,13 @@ test("add a one-time reminder", async ({ page }, info) => {
await page.waitForEvent("dialog");
});
test("adding a one-time reminder before current time should not be possible", async ({
page
}, info) => {
info.setTimeout(90 * 1000);
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
await reminders.createReminder({
...ONE_TIME_REMINDER,
date: 0
});
expect(
await app.toasts.waitForToast(
"Reminder time cannot be earlier than the current time."
)
).toBeTruthy();
});
for (const recurringMode of ["Daily", "Weekly", "Monthly"] as const) {
test(`add a recurring reminder (${recurringMode})`, async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait({
const reminder = await reminders.createReminder({
...ONE_TIME_REMINDER,
mode: "repeat",
recurringMode:
@@ -88,26 +67,11 @@ for (const recurringMode of ["Daily", "Weekly", "Monthly"] as const) {
});
}
test(`add a recurring reminder before current time`, async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait({
...ONE_TIME_REMINDER,
mode: "repeat",
recurringMode: "day",
date: 0
});
expect(reminder).toBeDefined();
});
test("delete a reminder", async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait(ONE_TIME_REMINDER);
const reminder = await reminders.createReminder(ONE_TIME_REMINDER);
await reminder?.delete();
@@ -125,7 +89,7 @@ test("edit a reminder", async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait(ONE_TIME_REMINDER);
const reminder = await reminders.createReminder(ONE_TIME_REMINDER);
const beforeReminderTime = await reminder?.getReminderTime();
const beforeDescription = await reminder?.getDescription();
const beforeTitle = await reminder?.getTitle();
@@ -145,7 +109,7 @@ test("disable a reminder", async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait(ONE_TIME_REMINDER);
const reminder = await reminders.createReminder(ONE_TIME_REMINDER);
await reminder?.toggle();
@@ -158,7 +122,7 @@ test("enable a disabled reminder", async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait(ONE_TIME_REMINDER);
const reminder = await reminders.createReminder(ONE_TIME_REMINDER);
await reminder?.toggle();
await reminder?.toggle();
@@ -167,27 +131,3 @@ test("enable a disabled reminder", async ({ page }) => {
expect(await reminders.findGroup("Active")).toBeDefined();
expect(await reminder?.isDisabled()).toBeFalsy();
});
test("editing a weekly recurring reminder should not revert it to daily", async ({
page
}) => {
const RECURRING_REMINDER: Partial<Reminder> = {
...ONE_TIME_REMINDER,
recurringMode: "week",
selectedDays: [0, 2],
mode: "repeat"
};
const app = new AppModel(page);
await app.goto();
const reminders = await app.goToReminders();
const reminder = await reminders.createReminderAndWait(RECURRING_REMINDER);
await reminder?.edit({
description: "An edited reminder"
});
expect(await reminder?.isPresent()).toBe(true);
expect(await reminder?.getRecurringMode()).toBe("Weekly");
expect(await reminder?.getDescription()).toBe("An edited reminder");
});

View File

@@ -1,117 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { NativeImage, nativeImage } from "electron";
import path from "path";
import { isDevelopment } from "./utils";
import { parse, ParsedImage } from "icojs";
import { readFileSync } from "fs";
import { getSystemTheme } from "./config/theme";
type Formats = "ico" | "png" | "icns";
type IconOptions<TFormat extends Formats> = {
size?: 16 | 22 | 24 | 32 | 48 | 64 | 128 | 256 | 512 | 1024;
format?: TFormat;
};
type IconNames = typeof icons[number];
type Prefixes = typeof prefixes[number];
type FlexibleIcon<TFormat extends Formats> = TFormat extends "ico"
? string
: NativeImage;
const RESOURCES_DIR = isDevelopment()
? process.cwd()
: process.platform === "darwin"
? path.normalize(path.join(path.dirname(process.execPath), "..", "Resources"))
: path.join(path.dirname(process.execPath), "resources");
const prefixes = ["", ".dark"];
const icons = [
"note-add",
"notebook-add",
"reminder-add",
"quit",
"tray-icon"
] as const;
const ALL_ICONS: {
id: IconNames;
prefix: Prefixes;
images: ParsedImage[];
}[] = [];
export class AssetManager {
static async loadIcons() {
if (ALL_ICONS.length) return;
for (const prefix of prefixes) {
for (const icon of icons) {
const icoPath = path.join(
RESOURCES_DIR,
"assets",
"icons",
`${icon}${prefix}.ico`
);
const icoBuffer = readFileSync(icoPath);
const images = await parse(icoBuffer, "image/png");
ALL_ICONS.push({ id: icon, images, prefix });
}
}
}
static appIcon(options: IconOptions<Formats>) {
const { size = 32, format = "png" } = options;
if (format === "ico") return path.join("assets", "icons", "app.ico");
if (format === "icns") return path.join("assets", "icons", "app.icns");
return path.join("assets", "icons", `${size}x${size}.png`);
}
static icon<TFormat extends Formats>(
name: IconNames,
options: IconOptions<TFormat>
): FlexibleIcon<TFormat> {
const { size = 16, format = "png" } = options;
const prefix: Prefixes = getSystemTheme() === "dark" ? ".dark" : "";
const icoPath = path.join(
RESOURCES_DIR,
"assets",
"icons",
`${name}${prefix}.ico`
);
if (format === "ico") return icoPath as FlexibleIcon<TFormat>;
const icon = ALL_ICONS.find((a) => a.id === name && a.prefix === prefix);
if (!icon)
return nativeImage.createFromPath(
AssetManager.appIcon(options)
) as FlexibleIcon<TFormat>;
return nativeImage.createFromBuffer(
Buffer.from(
(icon.images.find((i) => i.height === size) || icon.images[0]).buffer
)
) as FlexibleIcon<TFormat>;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Some files were not shown because too many files have changed in this diff Show More