mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-08-29 18:19:38 +02:00
Compare commits
358 Commits
2.2.5-andr
...
fix-loadin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
735ab21ee9 | ||
|
|
0d3504dca0 | ||
|
|
0f8f53d811 | ||
|
|
85aae88300 | ||
|
|
fc69b5ffd0 | ||
|
|
a7369bf869 | ||
|
|
2da32e27ff | ||
|
|
3e71ad0b0b | ||
|
|
a62ca2aada | ||
|
|
ffacb8818c | ||
|
|
7be867c7ca | ||
|
|
29f3dafc4f | ||
|
|
cfa35bbccd | ||
|
|
0a6cc165dc | ||
|
|
c5489e3c4a | ||
|
|
0ea5bd297c | ||
|
|
9116a24392 | ||
|
|
86fc16a8d0 | ||
|
|
62d3ead9a8 | ||
|
|
525828d6e0 | ||
|
|
6b71509b74 | ||
|
|
9e382b1d04 | ||
|
|
744d3c2312 | ||
|
|
e426d9d160 | ||
|
|
ba9b671f33 | ||
|
|
90cdd5f253 | ||
|
|
24b0f322c6 | ||
|
|
a8a031a161 | ||
|
|
b66741910f | ||
|
|
6ffa192f08 | ||
|
|
c80def5d95 | ||
|
|
63cf160cea | ||
|
|
7a40db9a36 | ||
|
|
edd7431de1 | ||
|
|
eb7c0cc049 | ||
|
|
51d130e3c3 | ||
|
|
241c914800 | ||
|
|
f254fc5c58 | ||
|
|
a74b910478 | ||
|
|
7f30fe6ff9 | ||
|
|
c6efa3ba6c | ||
|
|
020e41b3db | ||
|
|
7e9dc0e55c | ||
|
|
d1072059c5 | ||
|
|
388570ca8e | ||
|
|
1fa0203651 | ||
|
|
4dbd49d612 | ||
|
|
59a25610e3 | ||
|
|
a84611d5ee | ||
|
|
44827a1f1a | ||
|
|
66203afc92 | ||
|
|
127c4cd537 | ||
|
|
15ed1b498a | ||
|
|
d5793e9e4e | ||
|
|
e34114a3c4 | ||
|
|
961b953f5a | ||
|
|
e9a5f752a4 | ||
|
|
370ba5420a | ||
|
|
b3c4dbb910 | ||
|
|
4ed378bc9c | ||
|
|
39c234c698 | ||
|
|
00837a6790 | ||
|
|
f3f735392b | ||
|
|
b7dc9646f6 | ||
|
|
30a5882b9c | ||
|
|
7449181d86 | ||
|
|
68196b2d99 | ||
|
|
53116a6b2f | ||
|
|
31479943bb | ||
|
|
7b2de009a7 | ||
|
|
3746ebd0be | ||
|
|
2db03ed2d7 | ||
|
|
0f5786d7d7 | ||
|
|
2097e5777b | ||
|
|
1c0b8e9115 | ||
|
|
117303c471 | ||
|
|
b536e62533 | ||
|
|
9353b7b39d | ||
|
|
1799404c01 | ||
|
|
144e992eca | ||
|
|
373fa02280 | ||
|
|
1c66266f2d | ||
|
|
ce3e1cdd36 | ||
|
|
4ee9593bac | ||
|
|
5409ac666e | ||
|
|
18da6cfc43 | ||
|
|
c75f750215 | ||
|
|
e2f2f0866d | ||
|
|
6583ea6a47 | ||
|
|
25ae32028b | ||
|
|
e08a6db184 | ||
|
|
95e1daf7f7 | ||
|
|
165862db06 | ||
|
|
b7bce0d8cd | ||
|
|
4daca499d6 | ||
|
|
21bd6ffbd9 | ||
|
|
80f5ecb276 | ||
|
|
39cc58480c | ||
|
|
3be7a53668 | ||
|
|
54d65beae3 | ||
|
|
8e6bbb9227 | ||
|
|
a1440fd64c | ||
|
|
b0417387b4 | ||
|
|
cc3618cb02 | ||
|
|
9f832ce25d | ||
|
|
343da60428 | ||
|
|
5f3c89a93a | ||
|
|
9fb24748c9 | ||
|
|
6ff2f5c423 | ||
|
|
b439571e17 | ||
|
|
1b471a2fda | ||
|
|
2ce30b71c7 | ||
|
|
91ae351129 | ||
|
|
2966962016 | ||
|
|
3c38c61437 | ||
|
|
8edd1af18c | ||
|
|
4b65c546f2 | ||
|
|
defc640293 | ||
|
|
7e3d889632 | ||
|
|
fa24565e25 | ||
|
|
966130dc52 | ||
|
|
6ba3732327 | ||
|
|
c0bc786669 | ||
|
|
646dbfef6e | ||
|
|
3ea0faa7df | ||
|
|
e9fbf17b40 | ||
|
|
5c7e776dce | ||
|
|
0db0070aeb | ||
|
|
774cc6f953 | ||
|
|
abe1598910 | ||
|
|
4fe2f91175 | ||
|
|
eb526063c3 | ||
|
|
08e5c285e0 | ||
|
|
05cd7e5002 | ||
|
|
a0ad4403cb | ||
|
|
d0ddaeba73 | ||
|
|
06ad68975f | ||
|
|
c37aec07bb | ||
|
|
1fc0fd5694 | ||
|
|
9aad63a623 | ||
|
|
22871d8baf | ||
|
|
65cae7888e | ||
|
|
6718be881b | ||
|
|
d10c1eb8b7 | ||
|
|
3ef8e1bab1 | ||
|
|
ec699e8ef4 | ||
|
|
206b72a5f8 | ||
|
|
dd2a27337f | ||
|
|
e43ee80fdb | ||
|
|
04fe4a7217 | ||
|
|
a46857974c | ||
|
|
4a826cfaea | ||
|
|
8c87d00102 | ||
|
|
3fd1898422 | ||
|
|
12d1b3fcc9 | ||
|
|
e3f35ac567 | ||
|
|
47feaeeac1 | ||
|
|
377bd6e510 | ||
|
|
c150006ba2 | ||
|
|
9b747d1d2b | ||
|
|
fbfcfe1bcb | ||
|
|
360b94353a | ||
|
|
19227cf51b | ||
|
|
c6297227bf | ||
|
|
99d3b7300c | ||
|
|
b77254a045 | ||
|
|
1ef4dcb52c | ||
|
|
e4ba2acd99 | ||
|
|
fcc39034c4 | ||
|
|
352639da24 | ||
|
|
b65a372192 | ||
|
|
631142f852 | ||
|
|
19f0ee97f2 | ||
|
|
c8601c88a7 | ||
|
|
a8f0724b0f | ||
|
|
6a7d11c331 | ||
|
|
e2263701d3 | ||
|
|
d88fe47c55 | ||
|
|
f78d0cda1d | ||
|
|
7bde09c5d7 | ||
|
|
0fe0a4dc0b | ||
|
|
6e1db2ea33 | ||
|
|
d0991ae96b | ||
|
|
40e28f3ed4 | ||
|
|
87ba9ae027 | ||
|
|
8c8be28363 | ||
|
|
d4ec67ee21 | ||
|
|
26ec8551f9 | ||
|
|
484bc02a28 | ||
|
|
07ebbf622d | ||
|
|
2467b57a2e | ||
|
|
7375ce55b9 | ||
|
|
de9566dc75 | ||
|
|
b9a833cc8d | ||
|
|
febf742ea2 | ||
|
|
b7ebbfda1d | ||
|
|
6bd67d2599 | ||
|
|
32467c36af | ||
|
|
7ac8b478ed | ||
|
|
0398e99cdf | ||
|
|
79be55ab44 | ||
|
|
23fbf5ae15 | ||
|
|
225a671cab | ||
|
|
8e53e61db6 | ||
|
|
99ac6ec58f | ||
|
|
08ad464310 | ||
|
|
28a115ab04 | ||
|
|
a2c875acca | ||
|
|
c06f3ed351 | ||
|
|
26cbf6a522 | ||
|
|
54f9e27ef3 | ||
|
|
38a34857db | ||
|
|
3702bb0186 | ||
|
|
0dec8b5af4 | ||
|
|
946fd3fc1d | ||
|
|
baa06ebd6e | ||
|
|
a8f1fbf6a1 | ||
|
|
657fe05464 | ||
|
|
e7d0c956bc | ||
|
|
30cad32e26 | ||
|
|
ab9538c81e | ||
|
|
fc634f15bb | ||
|
|
e07a2c4984 | ||
|
|
4374af79bc | ||
|
|
5a540362c0 | ||
|
|
2beccd6918 | ||
|
|
d4a3b53c1b | ||
|
|
947b2099a1 | ||
|
|
c0212c64bc | ||
|
|
d291a536a6 | ||
|
|
cf918ba459 | ||
|
|
c3aa2dd62b | ||
|
|
5c8cf1beb5 | ||
|
|
2f92bf0de8 | ||
|
|
088235a46d | ||
|
|
2845cb19d6 | ||
|
|
db4126fe16 | ||
|
|
4eed06c91f | ||
|
|
00da012b3f | ||
|
|
db2041a15d | ||
|
|
5971253728 | ||
|
|
19a5e78495 | ||
|
|
919e46aea8 | ||
|
|
7b7fd62047 | ||
|
|
e71447c19d | ||
|
|
c28ef94cf1 | ||
|
|
4ac9bb2d9b | ||
|
|
433749d3fa | ||
|
|
92b1ebe744 | ||
|
|
3be4705be3 | ||
|
|
f83d6c2d37 | ||
|
|
2c8d6d115c | ||
|
|
29b9c897c4 | ||
|
|
85ada72054 | ||
|
|
64bf627462 | ||
|
|
eaace54154 | ||
|
|
003178ba20 | ||
|
|
56837208d1 | ||
|
|
f6493692e4 | ||
|
|
6269a8415b | ||
|
|
3d065f2278 | ||
|
|
64e8f8b9a9 | ||
|
|
9af102451d | ||
|
|
31d0164ba8 | ||
|
|
1a40c8ec77 | ||
|
|
c1674b6f05 | ||
|
|
c5faf62398 | ||
|
|
58a17f620b | ||
|
|
47dcbba522 | ||
|
|
7cd6a6e9ee | ||
|
|
e17bd79004 | ||
|
|
2fdbc9cb1d | ||
|
|
f7cc2d61b6 | ||
|
|
ad91da9f2d | ||
|
|
3037cf8cfb | ||
|
|
aa0bf3b3dc | ||
|
|
96a3d8edac | ||
|
|
611c229ece | ||
|
|
4b6880303c | ||
|
|
44a081fa54 | ||
|
|
7bf01535c8 | ||
|
|
b7b6f604eb | ||
|
|
6b601afe0f | ||
|
|
b65761f9da | ||
|
|
fcfe9ff23b | ||
|
|
a19fa2212a | ||
|
|
5445ee0335 | ||
|
|
d2f65c435d | ||
|
|
bbe21eb7db | ||
|
|
d39426a57a | ||
|
|
f43715cd24 | ||
|
|
503b5922e9 | ||
|
|
58319c27f5 | ||
|
|
f1a2afd9d6 | ||
|
|
8bc58b7869 | ||
|
|
dd0b0f4243 | ||
|
|
1f61742786 | ||
|
|
95dd84695b | ||
|
|
1500d50ba9 | ||
|
|
c206377198 | ||
|
|
7b5923ebc5 | ||
|
|
064b6fb9dc | ||
|
|
b101f42ff0 | ||
|
|
1b13e055d1 | ||
|
|
3c378809d0 | ||
|
|
c5fcc7e962 | ||
|
|
77c9db0faa | ||
|
|
ea07672a2d | ||
|
|
222fc00bd7 | ||
|
|
ae8c220119 | ||
|
|
0e96769e93 | ||
|
|
77c0f63dfd | ||
|
|
3f4021ea44 | ||
|
|
c52d5ad176 | ||
|
|
fbb8652946 | ||
|
|
4f8c2fa37a | ||
|
|
ea405393fd | ||
|
|
5e6caa7273 | ||
|
|
b1f5ffc2ec | ||
|
|
8af8b69cbf | ||
|
|
0c0dff3b28 | ||
|
|
3ab6c4646c | ||
|
|
98dfe30099 | ||
|
|
b0438bf71e | ||
|
|
2130c8a806 | ||
|
|
7c626aca18 | ||
|
|
30662f147a | ||
|
|
846adea92e | ||
|
|
f5a7beef17 | ||
|
|
82b584b3d1 | ||
|
|
68c79bcdd5 | ||
|
|
fe4a16f182 | ||
|
|
a70961b662 | ||
|
|
d14be59204 | ||
|
|
c3965a3b0e | ||
|
|
808270d2ef | ||
|
|
a8a8080835 | ||
|
|
3906de0715 | ||
|
|
0691e71227 | ||
|
|
d372c2daf9 | ||
|
|
b11387b385 | ||
|
|
8f5ebe315e | ||
|
|
8ae4ad6126 | ||
|
|
1823a4f4ba | ||
|
|
fa6e88a0b0 | ||
|
|
eacbbe2ad8 | ||
|
|
b2b64a172f | ||
|
|
84a687d69d | ||
|
|
860e97c97d | ||
|
|
4c6c42c794 | ||
|
|
205373dca3 | ||
|
|
349cd27650 | ||
|
|
fedfab094c | ||
|
|
f62c045350 | ||
|
|
a973a5cdf0 | ||
|
|
545c78361b | ||
|
|
d7a80c631b | ||
|
|
a650b8c2d9 |
@@ -20,6 +20,7 @@ const SCOPES = [
|
||||
"logger",
|
||||
"theme",
|
||||
"core",
|
||||
"clipper",
|
||||
"config",
|
||||
"ci",
|
||||
"setup",
|
||||
|
||||
@@ -18,6 +18,7 @@ apps/web/public/an.js
|
||||
|
||||
# editor
|
||||
packages/editor/styles/
|
||||
packages/editor/languages/
|
||||
|
||||
# editor mobile
|
||||
packages/editor-mobile/build.bundle
|
||||
@@ -2,7 +2,7 @@ const LICENSE = [
|
||||
"",
|
||||
"This file is part of the Notesnook project (https://notesnook.com/)",
|
||||
"",
|
||||
"Copyright (C) 2022 Streetwriters (Private) Limited",
|
||||
"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",
|
||||
|
||||
7
.github/workflows/core.tests.yml
vendored
7
.github/workflows/core.tests.yml
vendored
@@ -45,9 +45,10 @@ jobs:
|
||||
npm ci --prefer-offline --no-audit
|
||||
- name: Add environment variables
|
||||
run: |
|
||||
echo "EMAIL=${{ secrets.USER_EMAIL }}" >> $GITHUB_ENV
|
||||
echo "PASSWORD='${{ secrets.USER_PASSWORD }}'" >> $GITHUB_ENV
|
||||
echo "HASHED_PASSWORD=${{ secrets.USER_HASHED_PASSWORD }}" >> $GITHUB_ENV
|
||||
echo "USER_EMAIL=${{ secrets.USER_EMAIL }}" >> $GITHUB_ENV
|
||||
echo "USER_PASSWORD=${{ secrets.USER_PASSWORD }}" >> $GITHUB_ENV
|
||||
echo "USER_TOTP_SECRET=${{ secrets.USER_TOTP_SECRET }}" >> $GITHUB_ENV
|
||||
echo "USER_HASHED_PASSWORD=${{ secrets.USER_HASHED_PASSWORD }}" >> $GITHUB_ENV
|
||||
echo "NX_CLOUD_ACCESS_TOKEN=${{ secrets.NX_CLOUD_ACCESS_TOKEN }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Run all @notesnook/core tests
|
||||
|
||||
9
.github/workflows/web.tests.yml
vendored
9
.github/workflows/web.tests.yml
vendored
@@ -63,7 +63,7 @@ jobs:
|
||||
name: 🧪 Test (${{ matrix.shard }}/${{ strategy.job-total }})
|
||||
strategy:
|
||||
matrix:
|
||||
shard: [1, 2, 3]
|
||||
shard: [1, 2, 3, 4]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -95,7 +95,7 @@ jobs:
|
||||
- name: Install packages
|
||||
run: |
|
||||
npm i --ignore-scripts --prefer-offline --no-audit
|
||||
npm install -D @playwright/test
|
||||
npm install -D @playwright/test otplib
|
||||
|
||||
- name: Validate build extraction
|
||||
run: ls -ld ./apps/web/build/index.html
|
||||
@@ -107,8 +107,9 @@ jobs:
|
||||
- name: Add environment variables
|
||||
run: |
|
||||
echo "USER_EMAIL=${{ secrets.USER_EMAIL }}" >> $GITHUB_ENV
|
||||
echo "CURRENT_USER_PASSWORD=${{ secrets.USER_PASSWORD }}" >> $GITHUB_ENV
|
||||
echo "CURRENT_USER_KEY=${{ secrets.USER_KEY }}" >> $GITHUB_ENV
|
||||
echo "USER_PASSWORD=${{ secrets.USER_PASSWORD }}" >> $GITHUB_ENV
|
||||
echo "USER_TOTP_SECRET=${{ secrets.USER_TOTP_SECRET }}" >> $GITHUB_ENV
|
||||
echo "USER_KEY=${{ secrets.USER_KEY }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Run tests
|
||||
run: npx playwright test --shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,4 +3,7 @@ coverage
|
||||
node_modules
|
||||
dist
|
||||
.DS_STORE
|
||||
nx-cloud.env
|
||||
nx-cloud.env
|
||||
.idea
|
||||
.eslintcache
|
||||
.env.local
|
||||
@@ -4,5 +4,6 @@ module.exports = {
|
||||
semi: true,
|
||||
printWidth: 80,
|
||||
useTabs: false,
|
||||
tabWidth: 2
|
||||
tabWidth: 2,
|
||||
bracketSpacing: true
|
||||
};
|
||||
|
||||
1
AUTHORS
1
AUTHORS
@@ -1,3 +1,4 @@
|
||||
Notesnook is written & maintained by:
|
||||
- Abdullah Atta <abdullahatta@streetwriters.co>
|
||||
- Ammar Ahmed <ammarahmed6506@gmail.com>
|
||||
- Muhammad Ali <alihamuh@gmail.com>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -31,6 +31,15 @@ import { TipManager } from "./services/tip-manager";
|
||||
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) => {
|
||||
if (!response) return false;
|
||||
return response?.status >= 200 && response?.status < 300;
|
||||
}
|
||||
});
|
||||
|
||||
SettingsService.init();
|
||||
SettingsService.checkOrientation();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -21,7 +21,7 @@ import { Platform } from "react-native";
|
||||
import "react-native-get-random-values";
|
||||
import * as Keychain from "react-native-keychain";
|
||||
import { generateSecureRandom } from "react-native-securerandom";
|
||||
import Sodium from "react-native-sodium";
|
||||
import Sodium from "@ammarahmed/react-native-sodium";
|
||||
|
||||
const KEYSTORE_CONFIG = Platform.select({
|
||||
ios: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -25,10 +25,12 @@ import filesystem from "../filesystem";
|
||||
import EventSource from "../../utils/sse/even-source-ios";
|
||||
import AndroidEventSource from "../../utils/sse/event-source";
|
||||
import Storage, { KV } from "./storage";
|
||||
import * as Gzip from "react-native-gzip";
|
||||
|
||||
const LoggerStorage = new MMKVLoader()
|
||||
.withInstanceID("notesnook_logs")
|
||||
.initialize();
|
||||
initalize(new KV(LoggerStorage));
|
||||
initalize(new KV(LoggerStorage), true);
|
||||
export const DatabaseLogger = dbLogger;
|
||||
|
||||
/**
|
||||
@@ -37,7 +39,11 @@ export const DatabaseLogger = dbLogger;
|
||||
export var db = new Database(
|
||||
Storage,
|
||||
Platform.OS === "ios" ? EventSource : AndroidEventSource,
|
||||
filesystem
|
||||
filesystem,
|
||||
{
|
||||
compress: Gzip.deflate,
|
||||
decompress: Gzip.inflate
|
||||
}
|
||||
);
|
||||
|
||||
db.host(
|
||||
@@ -48,11 +54,11 @@ db.host(
|
||||
SSE_HOST: "https://events.streetwriters.co",
|
||||
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
|
||||
ISSUES_HOST: "https://issues.streetwriters.co"
|
||||
// API_HOST: 'http://192.168.10.29:5264',
|
||||
// AUTH_HOST: 'http://192.168.10.29:8264',
|
||||
// SSE_HOST: 'http://192.168.10.29:7264',
|
||||
// SUBSCRIPTIONS_HOST: 'http://192.168.10.29:9264',
|
||||
// ISSUES_HOST: 'http://192.168.10.29:2624'
|
||||
// API_HOST: "http://192.168.8.101:5264",
|
||||
// AUTH_HOST: "http://192.168.8.101:8264",
|
||||
// SSE_HOST: "http://192.168.8.101:7264",
|
||||
// SUBSCRIPTIONS_HOST: "http://192.168.8.101:9264",
|
||||
// ISSUES_HOST: "http://192.168.8.101:2624"
|
||||
}
|
||||
: {
|
||||
API_HOST: "https://api.notesnook.com",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import React from "react";
|
||||
import { Platform } from "react-native";
|
||||
import * as ScopedStorage from "react-native-scoped-storage";
|
||||
import Sodium from "react-native-sodium";
|
||||
import Sodium from "@ammarahmed/react-native-sodium";
|
||||
import RNFetchBlob from "rn-fetch-blob";
|
||||
import { ShareComponent } from "../../components/sheets/export-notes/share";
|
||||
import { presentSheet, ToastEvent } from "../../services/event-manager";
|
||||
@@ -68,7 +68,7 @@ export default async function downloadAttachment(hash, global = true) {
|
||||
chunkSize: attachment.chunkSize
|
||||
};
|
||||
|
||||
let fileUri = await Sodium.decryptFile(key, info, false);
|
||||
let fileUri = await Sodium.decryptFile(key, info, "file");
|
||||
ToastEvent.show({
|
||||
heading: "Download successful",
|
||||
message: attachment.metadata.filename + " downloaded",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -17,10 +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 {
|
||||
checkAttachment, downloadFile,
|
||||
getUploadedFileSize
|
||||
} from "./download";
|
||||
import { checkAttachment, downloadFile, getUploadedFileSize } from "./download";
|
||||
import {
|
||||
clearFileStorage,
|
||||
deleteFile,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Platform } from "react-native";
|
||||
import Sodium from "react-native-sodium";
|
||||
import Sodium from "@ammarahmed/react-native-sodium";
|
||||
import RNFetchBlob from "rn-fetch-blob";
|
||||
import { cacheDir, getRandomId } from "./utils";
|
||||
|
||||
@@ -36,13 +36,12 @@ export async function readEncrypted(filename, key, cipherData) {
|
||||
...cipherData,
|
||||
hash: filename
|
||||
},
|
||||
true
|
||||
cipherData.outputType === "base64" ? "base64" : "text"
|
||||
);
|
||||
return output;
|
||||
} catch (e) {
|
||||
RNFetchBlob.fs.unlink(path).catch(console.log);
|
||||
console.log(e);
|
||||
console.log("error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -23,10 +23,7 @@ import { Linking, View } from "react-native";
|
||||
import { eSendEvent, presentSheet } from "../../services/event-manager";
|
||||
import Sync from "../../services/sync";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import {
|
||||
eCloseAnnouncementDialog,
|
||||
eCloseProgressDialog
|
||||
} from "../../utils/events";
|
||||
import { eCloseAnnouncementDialog, eCloseSheet } from "../../utils/events";
|
||||
import { SIZE } from "../../utils/size";
|
||||
import { sleep } from "../../utils/time";
|
||||
import { PricingPlans } from "../premium/pricing-plans";
|
||||
@@ -60,11 +57,11 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
|
||||
)
|
||||
});
|
||||
} else if (item.type === "force-sync") {
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
eSendEvent(eCloseSheet);
|
||||
await sleep(300);
|
||||
Progress.present();
|
||||
Sync.run("global", true, true, () => {
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
eSendEvent(eCloseSheet);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -35,10 +35,7 @@ import PremiumService from "../../services/premium";
|
||||
import { useAttachmentStore } from "../../stores/use-attachment-store";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import { formatBytes } from "../../utils";
|
||||
import {
|
||||
eCloseAttachmentDialog,
|
||||
eCloseProgressDialog
|
||||
} from "../../utils/events";
|
||||
import { eCloseAttachmentDialog, eCloseSheet } from "../../utils/events";
|
||||
import { SIZE } from "../../utils/size";
|
||||
import { sleep } from "../../utils/time";
|
||||
import { Dialog } from "../dialog";
|
||||
@@ -71,7 +68,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
|
||||
useAttachmentStore.getState().remove(attachment.metadata.hash);
|
||||
}
|
||||
downloadAttachment(attachment.metadata.hash, false);
|
||||
eSendEvent(eCloseProgressDialog, contextId);
|
||||
eSendEvent(eCloseSheet, contextId);
|
||||
},
|
||||
icon: "download"
|
||||
},
|
||||
@@ -150,7 +147,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
|
||||
onPress: async () => {
|
||||
await db.attachments.remove(attachment.metadata.hash, false);
|
||||
setAttachments([...db.attachments.all]);
|
||||
eSendEvent(eCloseProgressDialog, contextId);
|
||||
eSendEvent(eCloseSheet, contextId);
|
||||
},
|
||||
icon: "delete-outline"
|
||||
}
|
||||
@@ -230,16 +227,18 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
|
||||
{formatBytes(attachment.length)}
|
||||
</Paragraph>
|
||||
|
||||
<Paragraph
|
||||
style={{
|
||||
marginRight: 10
|
||||
}}
|
||||
size={SIZE.xs + 1}
|
||||
color={colors.icon}
|
||||
>
|
||||
{attachment.noteIds.length} note
|
||||
{attachment.noteIds.length > 1 ? "s" : ""}
|
||||
</Paragraph>
|
||||
{attachment.noteIds ? (
|
||||
<Paragraph
|
||||
style={{
|
||||
marginRight: 10
|
||||
}}
|
||||
size={SIZE.xs + 1}
|
||||
color={colors.icon}
|
||||
>
|
||||
{attachment.noteIds.length} note
|
||||
{attachment.noteIds.length > 1 ? "s" : ""}
|
||||
</Paragraph>
|
||||
) : null}
|
||||
<Paragraph
|
||||
onPress={() => {
|
||||
Clipboard.setString(attachment.metadata.hash);
|
||||
@@ -291,7 +290,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
eSendEvent(eCloseProgressDialog, contextId);
|
||||
eSendEvent(eCloseSheet, contextId);
|
||||
await sleep(150);
|
||||
eSendEvent(eCloseAttachmentDialog);
|
||||
await sleep(300);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
ToastEvent
|
||||
} from "../../services/event-manager";
|
||||
import { useUserStore } from "../../stores/use-user-store";
|
||||
import { eCloseProgressDialog } from "../../utils/events";
|
||||
import { eCloseSheet } from "../../utils/events";
|
||||
import DialogHeader from "../dialog/dialog-header";
|
||||
import { Button } from "../ui/button";
|
||||
import Input from "../ui/input";
|
||||
@@ -72,7 +72,7 @@ export const ChangePassword = () => {
|
||||
context: "global"
|
||||
});
|
||||
setLoading(false);
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
eSendEvent(eCloseSheet);
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
ToastEvent.show({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -97,6 +97,9 @@ export const ForgotPassword = () => {
|
||||
text: email.current
|
||||
});
|
||||
}}
|
||||
indicatorStyle={{
|
||||
width: 100
|
||||
}}
|
||||
gestureEnabled
|
||||
id="forgotpassword_sheet"
|
||||
>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -17,18 +17,13 @@ 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, { useEffect, useRef, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated";
|
||||
import { db } from "../../common/database";
|
||||
import { DDS } from "../../services/device-detection";
|
||||
import { eSendEvent, ToastEvent } from "../../services/event-manager";
|
||||
import { clearMessage } from "../../services/message";
|
||||
import PremiumService from "../../services/premium";
|
||||
import SettingsService from "../../services/settings";
|
||||
import { eSendEvent } from "../../services/event-manager";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import { useUserStore } from "../../stores/use-user-store";
|
||||
import { SIZE } from "../../utils/size";
|
||||
import { sleep } from "../../utils/time";
|
||||
import BaseDialog from "../dialog/base-dialog";
|
||||
@@ -42,101 +37,48 @@ import Paragraph from "../ui/typography/paragraph";
|
||||
import { SVG } from "./background";
|
||||
import { hideAuth } from "./common";
|
||||
import { ForgotPassword } from "./forgot-password";
|
||||
import TwoFactorVerification from "./two-factor";
|
||||
import { useLogin } from "./use-login";
|
||||
|
||||
const LoginSteps = {
|
||||
emailAuth: 1,
|
||||
mfaAuth: 2,
|
||||
passwordAuth: 3
|
||||
};
|
||||
|
||||
export const Login = ({ changeMode }) => {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const email = useRef();
|
||||
const emailInputRef = useRef();
|
||||
const passwordInputRef = useRef();
|
||||
const password = useRef();
|
||||
const [focused, setFocused] = useState(false);
|
||||
const [error, setError] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const setUser = useUserStore((state) => state.setUser);
|
||||
|
||||
const validateInfo = () => {
|
||||
if (!password.current || !email.current) {
|
||||
ToastEvent.show({
|
||||
heading: "All fields required",
|
||||
message: "Fill all the fields and try again",
|
||||
type: "error",
|
||||
context: "local"
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
const {
|
||||
step,
|
||||
setStep,
|
||||
password,
|
||||
email,
|
||||
emailInputRef,
|
||||
passwordInputRef,
|
||||
loading,
|
||||
setLoading,
|
||||
setError,
|
||||
login
|
||||
} = useLogin(async () => {
|
||||
hideAuth();
|
||||
eSendEvent("userLoggedIn", true);
|
||||
await sleep(500);
|
||||
Progress.present();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
async () => {
|
||||
setStep(LoginSteps.emailAuth);
|
||||
await sleep(500);
|
||||
emailInputRef.current?.focus();
|
||||
setFocused(true);
|
||||
};
|
||||
return () => {
|
||||
setStep(LoginSteps.emailAuth);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const login = async (mfa, callback) => {
|
||||
if (!validateInfo() || error) return;
|
||||
setLoading(true);
|
||||
let user;
|
||||
try {
|
||||
if (mfa) {
|
||||
await db.user.mfaLogin(
|
||||
email.current.toLowerCase(),
|
||||
password.current,
|
||||
mfa
|
||||
);
|
||||
} else {
|
||||
await db.user.login(email.current.toLowerCase(), password.current);
|
||||
}
|
||||
callback && callback(true);
|
||||
|
||||
user = await db.user.getUser();
|
||||
if (!user) throw new Error("Email or password incorrect!");
|
||||
PremiumService.setPremiumStatus();
|
||||
setUser(user);
|
||||
clearMessage();
|
||||
ToastEvent.show({
|
||||
heading: "Login successful",
|
||||
message: `Logged in as ${user.email}`,
|
||||
type: "success",
|
||||
context: "global"
|
||||
});
|
||||
hideAuth();
|
||||
SettingsService.set({
|
||||
sessionExpired: false,
|
||||
userEmailConfirmed: user?.isEmailConfirmed
|
||||
});
|
||||
eSendEvent("userLoggedIn", true);
|
||||
await sleep(500);
|
||||
Progress.present();
|
||||
} catch (e) {
|
||||
callback && callback(false);
|
||||
if (e.message === "Multifactor authentication required.") {
|
||||
setLoading(false);
|
||||
await sleep(300);
|
||||
TwoFactorVerification.present(async (mfa) => {
|
||||
if (mfa) {
|
||||
await login(mfa);
|
||||
} else {
|
||||
setLoading(false);
|
||||
}
|
||||
}, e.data);
|
||||
} else {
|
||||
setLoading(false);
|
||||
ToastEvent.show({
|
||||
heading: user ? "Failed to sync" : "Login failed",
|
||||
message: e.message,
|
||||
type: "error",
|
||||
context: "local"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ForgotPassword />
|
||||
@@ -228,48 +170,54 @@ export const Login = ({ changeMode }) => {
|
||||
autoCorrect={false}
|
||||
autoCapitalize="none"
|
||||
errorMessage="Email is invalid"
|
||||
placeholder="Email"
|
||||
placeholder="Enter your email"
|
||||
defaultValue={email.current}
|
||||
editable={step === LoginSteps.emailAuth}
|
||||
onSubmit={() => {
|
||||
passwordInputRef.current?.focus();
|
||||
}}
|
||||
/>
|
||||
|
||||
<Input
|
||||
fwdRef={passwordInputRef}
|
||||
onChangeText={(value) => {
|
||||
password.current = value;
|
||||
}}
|
||||
testID="input.password"
|
||||
returnKeyLabel="Done"
|
||||
returnKeyType="done"
|
||||
secureTextEntry
|
||||
autoComplete="password"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="Password"
|
||||
marginBottom={0}
|
||||
onSubmit={() => login()}
|
||||
/>
|
||||
<Button
|
||||
title="Forgot your password?"
|
||||
style={{
|
||||
alignSelf: "flex-end",
|
||||
height: 30,
|
||||
paddingHorizontal: 0
|
||||
}}
|
||||
onPress={() => {
|
||||
SheetManager.show("forgotpassword_sheet", email.current);
|
||||
}}
|
||||
textStyle={{
|
||||
textDecorationLine: "underline"
|
||||
}}
|
||||
fontSize={SIZE.xs}
|
||||
type="gray"
|
||||
/>
|
||||
{step === LoginSteps.passwordAuth && (
|
||||
<>
|
||||
<Input
|
||||
fwdRef={passwordInputRef}
|
||||
onChangeText={(value) => {
|
||||
password.current = value;
|
||||
}}
|
||||
testID="input.password"
|
||||
returnKeyLabel="Done"
|
||||
returnKeyType="done"
|
||||
secureTextEntry
|
||||
autoComplete="password"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="Password"
|
||||
marginBottom={0}
|
||||
defaultValue={password.current}
|
||||
onSubmit={() => login()}
|
||||
/>
|
||||
<Button
|
||||
title="Forgot your password?"
|
||||
style={{
|
||||
alignSelf: "flex-end",
|
||||
height: 30,
|
||||
paddingHorizontal: 0
|
||||
}}
|
||||
onPress={() => {
|
||||
SheetManager.show("forgotpassword_sheet", email.current);
|
||||
}}
|
||||
textStyle={{
|
||||
textDecorationLine: "underline"
|
||||
}}
|
||||
fontSize={SIZE.xs}
|
||||
type="gray"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<View
|
||||
style={{
|
||||
// position: 'absolute',
|
||||
marginTop: 25,
|
||||
alignSelf: "center"
|
||||
}}
|
||||
@@ -280,11 +228,36 @@ export const Login = ({ changeMode }) => {
|
||||
borderRadius: 100
|
||||
}}
|
||||
loading={loading}
|
||||
onPress={() => login()}
|
||||
// width="100%"
|
||||
onPress={login}
|
||||
type="accent"
|
||||
title={loading ? null : "Login to your account"}
|
||||
title={
|
||||
loading
|
||||
? null
|
||||
: step === LoginSteps.emailAuth
|
||||
? "Login"
|
||||
: "Continue"
|
||||
}
|
||||
/>
|
||||
|
||||
{step === LoginSteps.passwordAuth && (
|
||||
<Button
|
||||
title="Cancel logging in"
|
||||
style={{
|
||||
alignSelf: "center",
|
||||
height: 30,
|
||||
marginTop: 10
|
||||
}}
|
||||
onPress={() => {
|
||||
setStep(LoginSteps.emailAuth);
|
||||
setLoading(false);
|
||||
}}
|
||||
textStyle={{
|
||||
textDecorationLine: "underline"
|
||||
}}
|
||||
fontSize={SIZE.xs}
|
||||
type="errorShade"
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</Animated.View>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -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, { useEffect, useRef, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Modal, View } from "react-native";
|
||||
import { db } from "../../common/database";
|
||||
import BiometricService from "../../services/biometrics";
|
||||
@@ -27,27 +27,23 @@ import {
|
||||
eUnSubscribeEvent,
|
||||
ToastEvent
|
||||
} from "../../services/event-manager";
|
||||
import { clearMessage } from "../../services/message";
|
||||
import PremiumService from "../../services/premium";
|
||||
import SettingsService from "../../services/settings";
|
||||
import Sync from "../../services/sync";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import { useUserStore } from "../../stores/use-user-store";
|
||||
import { SIZE } from "../../utils/size";
|
||||
import { sleep } from "../../utils/time";
|
||||
import { Dialog } from "../dialog";
|
||||
import { presentDialog } from "../dialog/functions";
|
||||
import SheetProvider from "../sheet-provider";
|
||||
import { Progress } from "../sheets/progress";
|
||||
import { Toast } from "../toast";
|
||||
import { Button } from "../ui/button";
|
||||
import { IconButton } from "../ui/icon-button";
|
||||
import Input from "../ui/input";
|
||||
import Heading from "../ui/typography/heading";
|
||||
import Paragraph from "../ui/typography/paragraph";
|
||||
import TwoFactorVerification from "./two-factor";
|
||||
import { LoginSteps, useLogin } from "./use-login";
|
||||
|
||||
function getEmail(email) {
|
||||
function getObfuscatedEmail(email) {
|
||||
if (!email) return null;
|
||||
return email.replace(/(.{2})(.*)(?=@)/, function (gp1, gp2, gp3) {
|
||||
for (let i = 0; i < gp3.length; i++) {
|
||||
@@ -59,15 +55,14 @@ function getEmail(email) {
|
||||
|
||||
export const SessionExpired = () => {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const email = useRef();
|
||||
const passwordInputRef = useRef();
|
||||
const password = useRef();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [focused, setFocused] = useState(false);
|
||||
|
||||
const setUser = useUserStore((state) => state.setUser);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { step, password, email, passwordInputRef, loading, login } = useLogin(
|
||||
() => {
|
||||
eSendEvent("userLoggedIn", true);
|
||||
setVisible(false);
|
||||
}
|
||||
);
|
||||
|
||||
const logout = async () => {
|
||||
try {
|
||||
@@ -92,9 +87,9 @@ export const SessionExpired = () => {
|
||||
eUnSubscribeEvent("session_expired", open);
|
||||
setFocused(false);
|
||||
};
|
||||
}, [visible]);
|
||||
}, [visible, open]);
|
||||
|
||||
const open = async () => {
|
||||
const open = React.useCallback(async () => {
|
||||
try {
|
||||
let res = await db.user.tokenManager.getToken();
|
||||
if (!res) throw new Error("no token found");
|
||||
@@ -120,64 +115,8 @@ export const SessionExpired = () => {
|
||||
email.current = user.email;
|
||||
setVisible(true);
|
||||
}
|
||||
};
|
||||
}, [email]);
|
||||
|
||||
const login = async (mfa, callback) => {
|
||||
setLoading(true);
|
||||
let user;
|
||||
try {
|
||||
if (mfa) {
|
||||
await db.user.mfaLogin(
|
||||
email.current.toLowerCase(),
|
||||
password.current,
|
||||
mfa
|
||||
);
|
||||
} else {
|
||||
await db.user.login(email.current.toLowerCase(), password.current);
|
||||
}
|
||||
callback && callback(true);
|
||||
setVisible(false);
|
||||
user = await db.user.getUser();
|
||||
if (!user) throw new Error("Email or password incorrect!");
|
||||
PremiumService.setPremiumStatus();
|
||||
setUser(user);
|
||||
clearMessage();
|
||||
ToastEvent.show({
|
||||
heading: "Login successful",
|
||||
message: `Logged in as ${user.email}`,
|
||||
type: "success",
|
||||
context: "global"
|
||||
});
|
||||
await SettingsService.set({
|
||||
sessionExpired: false,
|
||||
userEmailConfirmed: user?.isEmailConfirmed
|
||||
});
|
||||
eSendEvent("userLoggedIn", true);
|
||||
await sleep(500);
|
||||
Progress.present();
|
||||
setLoading(false);
|
||||
} catch (e) {
|
||||
callback && callback(false);
|
||||
if (e.message === "Multifactor authentication required.") {
|
||||
TwoFactorVerification.present(async (mfa) => {
|
||||
if (mfa) {
|
||||
await login(mfa);
|
||||
} else {
|
||||
setLoading(false);
|
||||
}
|
||||
}, e.data);
|
||||
} else {
|
||||
console.log(e.stack);
|
||||
setLoading(false);
|
||||
ToastEvent.show({
|
||||
heading: user ? "Failed to sync" : "Login failed",
|
||||
message: e.message,
|
||||
type: "error",
|
||||
context: "local"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
visible && (
|
||||
<Modal
|
||||
@@ -194,7 +133,8 @@ export const SessionExpired = () => {
|
||||
width: focused ? "100%" : "99.9%",
|
||||
padding: 12,
|
||||
justifyContent: "center",
|
||||
flex: 1
|
||||
flex: 1,
|
||||
backgroundColor: colors.bg
|
||||
}}
|
||||
>
|
||||
<View
|
||||
@@ -225,29 +165,32 @@ export const SessionExpired = () => {
|
||||
}}
|
||||
>
|
||||
Your session on this device has expired. Please enter password for{" "}
|
||||
{getEmail(email.current)} to continue.
|
||||
{getObfuscatedEmail(email.current)} to continue.
|
||||
</Paragraph>
|
||||
</View>
|
||||
|
||||
<Input
|
||||
fwdRef={passwordInputRef}
|
||||
onChangeText={(value) => {
|
||||
password.current = value;
|
||||
}}
|
||||
returnKeyLabel="Next"
|
||||
returnKeyType="next"
|
||||
secureTextEntry
|
||||
autoComplete="password"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="Password"
|
||||
onSubmit={() => login()}
|
||||
/>
|
||||
{step === LoginSteps.passwordAuth ? (
|
||||
<Input
|
||||
fwdRef={passwordInputRef}
|
||||
onChangeText={(value) => {
|
||||
password.current = value;
|
||||
}}
|
||||
returnKeyLabel="Next"
|
||||
returnKeyType="next"
|
||||
secureTextEntry
|
||||
autoComplete="password"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
placeholder="Password"
|
||||
onSubmit={() => login()}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<Button
|
||||
style={{
|
||||
marginTop: 10,
|
||||
width: "100%"
|
||||
width: 250,
|
||||
borderRadius: 100
|
||||
}}
|
||||
loading={loading}
|
||||
onPress={() => login()}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
ToastEvent
|
||||
} from "../../services/event-manager";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import { eCloseProgressDialog } from "../../utils/events";
|
||||
import { eCloseSheet } from "../../utils/events";
|
||||
import { SIZE } from "../../utils/size";
|
||||
import { Button } from "../ui/button";
|
||||
import { IconButton } from "../ui/icon-button";
|
||||
@@ -77,7 +77,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
|
||||
},
|
||||
(result) => {
|
||||
if (result) {
|
||||
eSendEvent(eCloseProgressDialog, "two_factor_verify");
|
||||
eSendEvent(eCloseSheet, "two_factor_verify");
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -204,6 +204,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
|
||||
placeholder={
|
||||
currentMethod.method === "recoveryCode" ? "xxxxxxxx" : "xxxxxx"
|
||||
}
|
||||
testID={"input.totp"}
|
||||
maxLength={currentMethod.method === "recoveryCode" ? 8 : 6}
|
||||
fwdRef={inputRef}
|
||||
textAlign="center"
|
||||
|
||||
155
apps/mobile/app/components/auth/use-login.js
Normal file
155
apps/mobile/app/components/auth/use-login.js
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
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 { useRef, useState } from "react";
|
||||
import { db } from "../../common/database";
|
||||
import { eSendEvent, ToastEvent } from "../../services/event-manager";
|
||||
import { clearMessage } from "../../services/message";
|
||||
import PremiumService from "../../services/premium";
|
||||
import SettingsService from "../../services/settings";
|
||||
import { useUserStore } from "../../stores/use-user-store";
|
||||
import { eCloseSheet } from "../../utils/events";
|
||||
import TwoFactorVerification from "./two-factor";
|
||||
|
||||
export const LoginSteps = {
|
||||
emailAuth: 1,
|
||||
mfaAuth: 2,
|
||||
passwordAuth: 3
|
||||
};
|
||||
|
||||
export const useLogin = (onFinishLogin) => {
|
||||
const [error, setError] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const setUser = useUserStore((state) => state.setUser);
|
||||
const [step, setStep] = useState(LoginSteps.emailAuth);
|
||||
const email = useRef();
|
||||
const password = useRef();
|
||||
const emailInputRef = useRef();
|
||||
const passwordInputRef = useRef();
|
||||
|
||||
const validateInfo = () => {
|
||||
if (
|
||||
(!password.current && step === LoginSteps.passwordAuth) ||
|
||||
(!email.current && step === LoginSteps.emailAuth)
|
||||
) {
|
||||
ToastEvent.show({
|
||||
heading: "All fields required",
|
||||
message: "Fill all the fields and try again",
|
||||
type: "error",
|
||||
context: "local"
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const login = async () => {
|
||||
if (!validateInfo() || error) return;
|
||||
try {
|
||||
setLoading(true);
|
||||
switch (step) {
|
||||
case LoginSteps.emailAuth: {
|
||||
const mfaInfo = await db.user.authenticateEmail(email.current);
|
||||
if (mfaInfo) {
|
||||
TwoFactorVerification.present(async (mfa, callback) => {
|
||||
try {
|
||||
const success = await db.user.authenticateMultiFactorCode(
|
||||
mfa.code,
|
||||
mfa.method
|
||||
);
|
||||
if (success) {
|
||||
setStep(LoginSteps.passwordAuth);
|
||||
setLoading(false);
|
||||
setTimeout(() => {
|
||||
passwordInputRef.current?.focus();
|
||||
}, 1);
|
||||
callback && callback(true);
|
||||
}
|
||||
callback && callback(false);
|
||||
} catch (e) {
|
||||
callback && callback(false);
|
||||
if (e.message === "invalid_grant") {
|
||||
eSendEvent(eCloseSheet, "two_factor_verify");
|
||||
setLoading(false);
|
||||
setStep(LoginSteps.emailAuth);
|
||||
}
|
||||
}
|
||||
}, mfaInfo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LoginSteps.passwordAuth: {
|
||||
await db.user.authenticatePassword(email.current, password.current);
|
||||
finishLogin();
|
||||
break;
|
||||
}
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (e) {
|
||||
finishWithError(e);
|
||||
}
|
||||
};
|
||||
|
||||
const finishWithError = async (e) => {
|
||||
if (e.message === "invalid_grant") setStep(LoginSteps.emailAuth);
|
||||
setLoading(false);
|
||||
ToastEvent.show({
|
||||
heading: "Login failed",
|
||||
message: e.message,
|
||||
type: "error",
|
||||
context: "local"
|
||||
});
|
||||
};
|
||||
|
||||
const finishLogin = async () => {
|
||||
const user = await db.user.getUser();
|
||||
if (!user) throw new Error("Email or password incorrect!");
|
||||
PremiumService.setPremiumStatus();
|
||||
setUser(user);
|
||||
clearMessage();
|
||||
ToastEvent.show({
|
||||
heading: "Login successful",
|
||||
message: `Logged in as ${user.email}`,
|
||||
type: "success",
|
||||
context: "global"
|
||||
});
|
||||
SettingsService.set({
|
||||
sessionExpired: false,
|
||||
userEmailConfirmed: user?.isEmailConfirmed
|
||||
});
|
||||
onFinishLogin?.();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return {
|
||||
login,
|
||||
step,
|
||||
setStep,
|
||||
email,
|
||||
password,
|
||||
passwordInputRef,
|
||||
emailInputRef,
|
||||
loading,
|
||||
setLoading,
|
||||
error,
|
||||
setError
|
||||
};
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -35,6 +35,7 @@ type DialogHeaderProps = {
|
||||
loading?: boolean;
|
||||
title?: string;
|
||||
type?: PressableButtonProps["type"];
|
||||
icon?: string;
|
||||
};
|
||||
paragraphColor?: string;
|
||||
padding?: number;
|
||||
@@ -96,6 +97,7 @@ const DialogHeader = ({
|
||||
loading={button.loading}
|
||||
fontSize={13}
|
||||
title={button.title}
|
||||
icon={button.icon}
|
||||
type={button.type || "grayBg"}
|
||||
height={25}
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -23,7 +23,7 @@ import Icon from "react-native-vector-icons/MaterialCommunityIcons";
|
||||
import { eSendEvent } from "../../../services/event-manager";
|
||||
import { useThemeStore } from "../../../stores/use-theme-store";
|
||||
import {
|
||||
eCloseProgressDialog,
|
||||
eCloseSheet,
|
||||
eCloseResultDialog,
|
||||
eOpenPremiumDialog
|
||||
} from "../../../utils/events";
|
||||
@@ -82,7 +82,7 @@ export const ProFeatures = ({ count = 6 }) => {
|
||||
<Paragraph
|
||||
onPress={async () => {
|
||||
eSendEvent(eCloseResultDialog);
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
eSendEvent(eCloseSheet);
|
||||
await sleep(300);
|
||||
eSendEvent(eOpenPremiumDialog);
|
||||
}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -32,6 +32,7 @@ import { SIZE } from "../../utils/size";
|
||||
import Heading from "../ui/typography/heading";
|
||||
import Paragraph from "../ui/typography/paragraph";
|
||||
import { useCallback } from "react";
|
||||
import Tag from "../ui/tag";
|
||||
|
||||
const titleState = {};
|
||||
|
||||
@@ -104,7 +105,8 @@ export const Title = () => {
|
||||
style={{
|
||||
opacity: 1,
|
||||
flexShrink: 1,
|
||||
flexDirection: "row"
|
||||
flexDirection: "row",
|
||||
alignItems: "center"
|
||||
}}
|
||||
>
|
||||
{!hide && !isHidden ? (
|
||||
@@ -135,6 +137,7 @@ export const Title = () => {
|
||||
{title}
|
||||
</Heading>
|
||||
) : null}
|
||||
<Tag visible={currentScreen.beta} text="BETA" />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -27,8 +27,7 @@ import { useAppState } from "../../hooks/use-app-state";
|
||||
import BiometricService from "../../services/biometrics";
|
||||
import {
|
||||
eSendEvent,
|
||||
presentSheet,
|
||||
ToastEvent
|
||||
presentSheet
|
||||
} from "../../services/event-manager";
|
||||
import { setRateAppMessage } from "../../services/message";
|
||||
import PremiumService from "../../services/premium";
|
||||
@@ -155,7 +154,7 @@ const Launcher = React.memo(
|
||||
if (__DEV__) return;
|
||||
try {
|
||||
const version =
|
||||
Config.GITHUB_RELEASE !== "true"
|
||||
Config.GITHUB_RELEASE === "true"
|
||||
? await getGithubVersion()
|
||||
: await checkVersion();
|
||||
if (!version || !version?.needsUpdate) return false;
|
||||
@@ -199,13 +198,7 @@ const Launcher = React.memo(
|
||||
};
|
||||
|
||||
const onUnlockBiometrics = useCallback(async () => {
|
||||
if (!(await BiometricService.isBiometryAvailable())) {
|
||||
ToastEvent.show({
|
||||
heading: "Biometrics unavailable",
|
||||
message: "Try unlocking the app with your account password"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!(await BiometricService.isBiometryAvailable())) return;
|
||||
let verified = await BiometricService.validateUser(
|
||||
"Unlock to access your notes",
|
||||
""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -122,7 +122,7 @@ export const SectionHeader = React.memo(
|
||||
alignItems: "center"
|
||||
}}
|
||||
>
|
||||
{index === 0 ? (
|
||||
{index === 0 && (
|
||||
<>
|
||||
<Button
|
||||
onPress={() => {
|
||||
@@ -130,6 +130,7 @@ export const SectionHeader = React.memo(
|
||||
component: <Sort screen={screen} type={type} />
|
||||
});
|
||||
}}
|
||||
hidden={screen === "Reminders"}
|
||||
tooltipText="Change sorting of items in list"
|
||||
fwdRef={sortRef}
|
||||
title={groupBy}
|
||||
@@ -152,38 +153,35 @@ export const SectionHeader = React.memo(
|
||||
iconPosition="right"
|
||||
/>
|
||||
|
||||
{type === "notes" || type === "notebooks" || type === "home" ? (
|
||||
<IconButton
|
||||
customStyle={{
|
||||
width: 25,
|
||||
height: 25
|
||||
}}
|
||||
testID="icon-compact-mode"
|
||||
tooltipText={
|
||||
listMode == "compact"
|
||||
? "Switch to normal mode"
|
||||
: "Switch to compact mode"
|
||||
}
|
||||
fwdRef={compactModeRef}
|
||||
color={colors.icon}
|
||||
name={
|
||||
listMode == "compact" ? "view-list" : "view-list-outline"
|
||||
}
|
||||
onPress={() => {
|
||||
let settings = {};
|
||||
settings[
|
||||
type !== "notebooks"
|
||||
? "notesListMode"
|
||||
: "notebooksListMode"
|
||||
] = listMode === "normal" ? "compact" : "normal";
|
||||
<IconButton
|
||||
customStyle={{
|
||||
width: 25,
|
||||
height: 25
|
||||
}}
|
||||
hidden={
|
||||
type !== "notes" && type !== "notebooks" && type !== "home"
|
||||
}
|
||||
testID="icon-compact-mode"
|
||||
tooltipText={
|
||||
listMode == "compact"
|
||||
? "Switch to normal mode"
|
||||
: "Switch to compact mode"
|
||||
}
|
||||
fwdRef={compactModeRef}
|
||||
color={colors.icon}
|
||||
name={listMode == "compact" ? "view-list" : "view-list-outline"}
|
||||
onPress={() => {
|
||||
let settings = {};
|
||||
settings[
|
||||
type !== "notebooks" ? "notesListMode" : "notebooksListMode"
|
||||
] = listMode === "normal" ? "compact" : "normal";
|
||||
|
||||
SettingsService.set(settings);
|
||||
}}
|
||||
size={SIZE.lg - 2}
|
||||
/>
|
||||
) : null}
|
||||
SettingsService.set(settings);
|
||||
}}
|
||||
size={SIZE.lg - 2}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -17,6 +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 { getUpcomingReminder } from "@notesnook/core/collections/reminders";
|
||||
import { decode, EntityLevel } from "entities";
|
||||
import React from "react";
|
||||
import { View } from "react-native";
|
||||
@@ -25,6 +26,7 @@ import { notesnook } from "../../../../e2e/test.ids";
|
||||
import { db } from "../../../common/database";
|
||||
import { TaggedNotes } from "../../../screens/notes/tagged";
|
||||
import { TopicNotes } from "../../../screens/notes/topic-notes";
|
||||
import { useRelationStore } from "../../../stores/use-relation-store";
|
||||
import { useSettingStore } from "../../../stores/use-setting-store";
|
||||
import { useThemeStore } from "../../../stores/use-theme-store";
|
||||
import { COLORS_NOTE } from "../../../utils/color-scheme";
|
||||
@@ -32,6 +34,7 @@ import { SIZE } from "../../../utils/size";
|
||||
import { Properties } from "../../properties";
|
||||
import { Button } from "../../ui/button";
|
||||
import { IconButton } from "../../ui/icon-button";
|
||||
import { ReminderTime } from "../../ui/reminder-time";
|
||||
import { TimeSince } from "../../ui/time-since";
|
||||
import Heading from "../../ui/typography/heading";
|
||||
import Paragraph from "../../ui/typography/paragraph";
|
||||
@@ -86,7 +89,10 @@ const NoteItem = ({
|
||||
const compactMode = notesListMode === "compact";
|
||||
const attachmentCount = db.attachments?.ofNote(item.id, "all")?.length || 0;
|
||||
const notebooks = React.useMemo(() => getNotebook(item), [item]);
|
||||
|
||||
const reminders = db.relations.from(item, "reminder");
|
||||
const reminder = getUpcomingReminder(reminders);
|
||||
const _update = useRelationStore((state) => state.updater);
|
||||
const noteColor = COLORS_NOTE[item.color?.toLowerCase()];
|
||||
return (
|
||||
<>
|
||||
<View
|
||||
@@ -102,14 +108,15 @@ const NoteItem = ({
|
||||
alignItems: "center",
|
||||
zIndex: 10,
|
||||
elevation: 10,
|
||||
marginBottom: 2.5
|
||||
marginBottom: 2.5,
|
||||
flexWrap: "wrap"
|
||||
}}
|
||||
>
|
||||
{notebooks?.map((_item) => (
|
||||
<Button
|
||||
title={_item.title}
|
||||
key={_item}
|
||||
height={20}
|
||||
height={25}
|
||||
icon="book-outline"
|
||||
type="grayBg"
|
||||
fontSize={SIZE.xs}
|
||||
@@ -122,11 +129,23 @@ const NoteItem = ({
|
||||
marginRight: 5,
|
||||
borderWidth: 0.5,
|
||||
borderColor: colors.icon,
|
||||
paddingHorizontal: 6
|
||||
paddingHorizontal: 6,
|
||||
marginBottom: 5
|
||||
}}
|
||||
onPress={() => navigateToTopic(_item.topic)}
|
||||
/>
|
||||
))}
|
||||
|
||||
<ReminderTime
|
||||
reminder={reminder}
|
||||
color={noteColor}
|
||||
onPress={() => {
|
||||
Properties.present(reminder);
|
||||
}}
|
||||
style={{
|
||||
height: 25
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -20,21 +20,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import React from "react";
|
||||
import NoteItem from ".";
|
||||
import { notesnook } from "../../../../e2e/test.ids";
|
||||
import { useSelectionStore } from "../../../stores/use-selection-store";
|
||||
import { useTrashStore } from "../../../stores/use-trash-store";
|
||||
import { useEditorStore } from "../../../stores/use-editor-store";
|
||||
import { db } from "../../../common/database";
|
||||
import { DDS } from "../../../services/device-detection";
|
||||
import {
|
||||
eSendEvent,
|
||||
hideSheet,
|
||||
openVault,
|
||||
ToastEvent
|
||||
presentSheet
|
||||
} from "../../../services/event-manager";
|
||||
import Navigation from "../../../services/navigation";
|
||||
import { useEditorStore } from "../../../stores/use-editor-store";
|
||||
import { useSelectionStore } from "../../../stores/use-selection-store";
|
||||
import { history } from "../../../utils";
|
||||
import { db } from "../../../common/database";
|
||||
import { eOnLoadNote, eShowMergeDialog } from "../../../utils/events";
|
||||
import { tabBarRef } from "../../../utils/global-refs";
|
||||
import { presentDialog } from "../../dialog/functions";
|
||||
import NotePreview from "../../note-history/preview";
|
||||
import SelectionWrapper from "../selection-wrapper";
|
||||
|
||||
const present = () =>
|
||||
@@ -44,9 +44,9 @@ const present = () =>
|
||||
paragraph: "Please sync again to open this note for editing"
|
||||
});
|
||||
|
||||
export const openNote = async (item, isTrash, setSelectedItem) => {
|
||||
export const openNote = async (item, isTrash, setSelectedItem, isSheet) => {
|
||||
let _note = item;
|
||||
|
||||
if (isSheet) hideSheet();
|
||||
if (!isTrash) {
|
||||
_note = db.notes.note(item.id).data;
|
||||
if (!db.notes.note(item.id)?.synced()) {
|
||||
@@ -84,39 +84,11 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
|
||||
return;
|
||||
}
|
||||
if (isTrash) {
|
||||
presentDialog({
|
||||
title: `Restore ${item.itemType}`,
|
||||
paragraph: `Restore or delete ${item.itemType} forever`,
|
||||
positiveText: "Restore",
|
||||
negativeText: "Delete",
|
||||
positivePress: async () => {
|
||||
await db.trash.restore(item.id);
|
||||
Navigation.queueRoutesForUpdate(
|
||||
"Tags",
|
||||
"Notes",
|
||||
"Notebooks",
|
||||
"Favorites",
|
||||
"Trash",
|
||||
"TaggedNotes",
|
||||
"ColoredNotes",
|
||||
"TopicNotes"
|
||||
);
|
||||
useSelectionStore.getState().setSelectionMode(false);
|
||||
ToastEvent.show({
|
||||
heading: "Restore successful",
|
||||
type: "success"
|
||||
});
|
||||
},
|
||||
onClose: async () => {
|
||||
await db.trash.delete(item.id);
|
||||
useTrashStore.getState().setTrash();
|
||||
useSelectionStore.getState().setSelectionMode(false);
|
||||
ToastEvent.show({
|
||||
heading: "Permanantly deleted items",
|
||||
type: "success",
|
||||
context: "local"
|
||||
});
|
||||
}
|
||||
const content = await db.content.get(item.contentId);
|
||||
presentSheet({
|
||||
component: (
|
||||
<NotePreview note={item} content={{ type: "tiptap", data: content }} />
|
||||
)
|
||||
});
|
||||
} else {
|
||||
useEditorStore.getState().setReadonly(_note?.readonly);
|
||||
@@ -128,7 +100,7 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
|
||||
};
|
||||
|
||||
export const NoteWrapper = React.memo(
|
||||
function NoteWrapper({ item, index, tags, dateBy }) {
|
||||
function NoteWrapper({ item, index, tags, dateBy, isSheet }) {
|
||||
const isTrash = item.type === "trash";
|
||||
const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
|
||||
|
||||
@@ -137,7 +109,8 @@ export const NoteWrapper = React.memo(
|
||||
index={index}
|
||||
height={100}
|
||||
testID={notesnook.ids.note.get(index)}
|
||||
onPress={() => openNote(item, isTrash, setSelectedItem)}
|
||||
onPress={() => openNote(item, isTrash, setSelectedItem, isSheet)}
|
||||
isSheet={isSheet}
|
||||
item={item}
|
||||
>
|
||||
<NoteItem item={item} dateBy={dateBy} tags={tags} isTrash={isTrash} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -24,7 +24,7 @@ import { notesnook } from "../../../../e2e/test.ids";
|
||||
import { TopicNotes } from "../../../screens/notes/topic-notes";
|
||||
import { useSettingStore } from "../../../stores/use-setting-store";
|
||||
import { useThemeStore } from "../../../stores/use-theme-store";
|
||||
import { getTotalNotes, history } from "../../../utils";
|
||||
import { history } from "../../../utils";
|
||||
import { SIZE } from "../../../utils/size";
|
||||
import { Properties } from "../../properties";
|
||||
import { Button } from "../../ui/button";
|
||||
@@ -131,16 +131,6 @@ export const NotebookItem = ({
|
||||
height: SIZE.md + 2
|
||||
}}
|
||||
>
|
||||
<Paragraph
|
||||
color={colors.accent}
|
||||
size={SIZE.xs}
|
||||
style={{
|
||||
marginRight: 6
|
||||
}}
|
||||
>
|
||||
{isTopic ? "Topic" : "Notebook"}
|
||||
</Paragraph>
|
||||
|
||||
{isTrash ? (
|
||||
<>
|
||||
<Paragraph
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
188
apps/mobile/app/components/list-items/reminder/index.tsx
Normal file
188
apps/mobile/app/components/list-items/reminder/index.tsx
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
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 { View } from "react-native";
|
||||
import { notesnook } from "../../../../e2e/test.ids";
|
||||
import type { Reminder } from "../../../services/notifications";
|
||||
import { useThemeStore } from "../../../stores/use-theme-store";
|
||||
import { SIZE } from "../../../utils/size";
|
||||
import { Properties } from "../../properties";
|
||||
import { IconButton } from "../../ui/icon-button";
|
||||
import Heading from "../../ui/typography/heading";
|
||||
import Paragraph from "../../ui/typography/paragraph";
|
||||
import SelectionWrapper from "../selection-wrapper";
|
||||
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
|
||||
import ReminderSheet from "../../sheets/reminder";
|
||||
import { ReminderTime } from "../../ui/reminder-time";
|
||||
|
||||
const ReminderItem = React.memo(
|
||||
({
|
||||
item,
|
||||
index,
|
||||
isSheet
|
||||
}: {
|
||||
item: Reminder;
|
||||
index: number;
|
||||
isSheet: boolean;
|
||||
}) => {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const openReminder = () => {
|
||||
ReminderSheet.present(item, undefined, isSheet);
|
||||
};
|
||||
return (
|
||||
<SelectionWrapper
|
||||
//@ts-ignore
|
||||
index={index}
|
||||
height={100}
|
||||
onPress={openReminder}
|
||||
item={item}
|
||||
isSheet={isSheet}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flexWrap: "wrap",
|
||||
flexShrink: 1,
|
||||
opacity: item.disabled ? 0.5 : 1
|
||||
}}
|
||||
>
|
||||
<Heading
|
||||
numberOfLines={1}
|
||||
style={{
|
||||
flexWrap: "wrap"
|
||||
}}
|
||||
size={SIZE.md}
|
||||
>
|
||||
{item.title}
|
||||
</Heading>
|
||||
|
||||
{item.description ? (
|
||||
<Paragraph
|
||||
style={{
|
||||
flexWrap: "wrap"
|
||||
}}
|
||||
numberOfLines={2}
|
||||
>
|
||||
{item.description}
|
||||
</Paragraph>
|
||||
) : null}
|
||||
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
flexWrap: "wrap"
|
||||
}}
|
||||
>
|
||||
{item.disabled ? (
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: colors.nav,
|
||||
borderRadius: 5,
|
||||
flexDirection: "row",
|
||||
paddingHorizontal: 5,
|
||||
paddingVertical: 3,
|
||||
alignItems: "center",
|
||||
marginTop: 5,
|
||||
justifyContent: "flex-start",
|
||||
alignSelf: "flex-start",
|
||||
marginRight: 10
|
||||
}}
|
||||
>
|
||||
<Icon
|
||||
name="bell-off-outline"
|
||||
size={SIZE.md}
|
||||
color={colors.errorText}
|
||||
/>
|
||||
<Paragraph
|
||||
size={SIZE.xs + 1}
|
||||
color={colors.icon}
|
||||
style={{ marginLeft: 5 }}
|
||||
>
|
||||
Disabled
|
||||
</Paragraph>
|
||||
</View>
|
||||
) : null}
|
||||
{item.mode === "repeat" && item.recurringMode ? (
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: colors.nav,
|
||||
borderRadius: 5,
|
||||
flexDirection: "row",
|
||||
paddingHorizontal: 5,
|
||||
paddingVertical: 3,
|
||||
alignItems: "center",
|
||||
marginTop: 5,
|
||||
justifyContent: "flex-start",
|
||||
alignSelf: "flex-start",
|
||||
marginRight: 10
|
||||
}}
|
||||
>
|
||||
<Icon name="reload" size={SIZE.md} color={colors.accent} />
|
||||
<Paragraph
|
||||
size={SIZE.xs + 1}
|
||||
color={colors.icon}
|
||||
style={{ marginLeft: 5 }}
|
||||
>
|
||||
{item.recurringMode.slice(0, 1).toUpperCase() +
|
||||
item.recurringMode.replace("y", "i").slice(1) +
|
||||
"ly"}
|
||||
</Paragraph>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<ReminderTime
|
||||
reminder={item}
|
||||
checkIsActive={false}
|
||||
fontSize={SIZE.xs + 1}
|
||||
style={{
|
||||
justifyContent: "flex-start",
|
||||
borderWidth: 0,
|
||||
height: 30,
|
||||
alignSelf: "flex-start",
|
||||
marginTop: 5
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<IconButton
|
||||
testID={notesnook.listitem.menu}
|
||||
color={colors.pri}
|
||||
name="dots-horizontal"
|
||||
size={SIZE.xl}
|
||||
onPress={() => Properties.present(item, [], isSheet)}
|
||||
customStyle={{
|
||||
justifyContent: "center",
|
||||
height: 35,
|
||||
width: 35,
|
||||
borderRadius: 100,
|
||||
alignItems: "center"
|
||||
}}
|
||||
/>
|
||||
</SelectionWrapper>
|
||||
);
|
||||
},
|
||||
(prev, next) => {
|
||||
if (prev.item?.dateModified !== next.item?.dateModified) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
);
|
||||
ReminderItem.displayName = "ReminderItem";
|
||||
|
||||
export default ReminderItem;
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -26,6 +26,7 @@ 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";
|
||||
@@ -138,7 +139,7 @@ export const ActionStrip = ({ note, setActionStrip }) => {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
visible: note.type !== "note"
|
||||
visible: note.type !== "note" && note.type !== "reminder"
|
||||
},
|
||||
{
|
||||
title: "Copy Note",
|
||||
@@ -223,6 +224,22 @@ export const ActionStrip = ({ note, setActionStrip }) => {
|
||||
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) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -29,6 +29,7 @@ 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,8 +37,10 @@ const SelectionWrapper = ({
|
||||
background,
|
||||
onLongPress,
|
||||
onPress,
|
||||
testID
|
||||
testID,
|
||||
isSheet
|
||||
}) => {
|
||||
const itemId = useRef(item.id);
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const [actionStrip, setActionStrip] = useState(false);
|
||||
const notebooksListMode = useSettingStore(
|
||||
@@ -51,6 +54,13 @@ const SelectionWrapper = ({
|
||||
(item.type === "notebook" || item.type === "note") &&
|
||||
listMode === "compact";
|
||||
|
||||
if (item.id !== itemId.current) {
|
||||
itemId.current = item.id;
|
||||
if (actionStrip) {
|
||||
setActionStrip(false);
|
||||
}
|
||||
}
|
||||
|
||||
const _onLongPress = () => {
|
||||
if (history.selectedItemsList.length > 0) return;
|
||||
setActionStrip(!actionStrip);
|
||||
@@ -75,10 +85,9 @@ const SelectionWrapper = ({
|
||||
eUnSubscribeEvent("navigate", closeStrip);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PressableButton
|
||||
customColor="transparent"
|
||||
customColor={isSheet ? colors.transGray : "transparent"}
|
||||
testID={testID}
|
||||
onLongPress={_onLongPress}
|
||||
onPress={_onPress}
|
||||
@@ -90,10 +99,11 @@ const SelectionWrapper = ({
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
borderRadius: 0,
|
||||
overflow: "hidden",
|
||||
paddingHorizontal: 12,
|
||||
paddingVertical: compactMode ? 8 : 12
|
||||
paddingVertical: compactMode ? 8 : 12,
|
||||
borderRadius: isSheet ? 10 : 0,
|
||||
marginBottom: isSheet ? 12 : undefined
|
||||
}}
|
||||
>
|
||||
{item.type === "note" ? (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -47,7 +47,7 @@ export const Card = ({ color, warning }) => {
|
||||
width: "95%",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-start",
|
||||
justifyContent: "space-between",
|
||||
paddingHorizontal: 0
|
||||
}}
|
||||
>
|
||||
@@ -59,7 +59,6 @@ export const Card = ({ color, warning }) => {
|
||||
? hexToRGBA(colors.red, 0.15)
|
||||
: hexToRGBA(color, 0.15),
|
||||
height: 40,
|
||||
marginLeft: 10,
|
||||
borderRadius: 100,
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
@@ -77,7 +76,8 @@ export const Card = ({ color, warning }) => {
|
||||
<View
|
||||
style={{
|
||||
marginLeft: 10,
|
||||
maxWidth: "70%"
|
||||
flexShrink: 1,
|
||||
marginRight: 10
|
||||
}}
|
||||
>
|
||||
<Paragraph color={colors.icon} size={SIZE.xs}>
|
||||
@@ -85,7 +85,8 @@ export const Card = ({ color, warning }) => {
|
||||
</Paragraph>
|
||||
<Paragraph
|
||||
style={{
|
||||
maxWidth: "100%"
|
||||
flexWrap: "wrap",
|
||||
flexShrink: 1
|
||||
}}
|
||||
color={colors.heading}
|
||||
>
|
||||
@@ -98,9 +99,7 @@ export const Card = ({ color, warning }) => {
|
||||
width: 40,
|
||||
height: 40,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
position: "absolute",
|
||||
right: 6
|
||||
alignItems: "center"
|
||||
}}
|
||||
>
|
||||
<Icon
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import React, { useRef } from "react";
|
||||
import { FlatList, RefreshControl, View } from "react-native";
|
||||
import { RefreshControl, View } from "react-native";
|
||||
import { FlashList } from "@shopify/flash-list";
|
||||
import Animated, { FadeInDown } from "react-native-reanimated";
|
||||
import { notesnook } from "../../../e2e/test.ids";
|
||||
import { eSendEvent } from "../../services/event-manager";
|
||||
@@ -36,6 +37,8 @@ import { NotebookWrapper } from "../list-items/notebook/wrapper";
|
||||
import TagItem from "../list-items/tag";
|
||||
import { Empty } from "./empty";
|
||||
import { getTotalNotes } from "../../utils";
|
||||
import { useSettingStore } from "../../stores/use-setting-store";
|
||||
import ReminderItem from "../list-items/reminder";
|
||||
|
||||
const renderItems = {
|
||||
note: NoteWrapper,
|
||||
@@ -43,7 +46,8 @@ const renderItems = {
|
||||
topic: NotebookWrapper,
|
||||
tag: TagItem,
|
||||
section: SectionHeader,
|
||||
header: SectionHeader
|
||||
header: SectionHeader,
|
||||
reminder: ReminderItem
|
||||
};
|
||||
|
||||
const RenderItem = ({ item, index, type, ...restArgs }) => {
|
||||
@@ -52,7 +56,6 @@ const RenderItem = ({ item, index, type, ...restArgs }) => {
|
||||
const groupOptions = db.settings?.getGroupOptions(type);
|
||||
const dateBy =
|
||||
groupOptions.sortBy !== "title" ? groupOptions.sortBy : "dateEdited";
|
||||
|
||||
const totalNotes = getTotalNotes(item);
|
||||
const tags =
|
||||
item.tags
|
||||
@@ -81,6 +84,11 @@ const RenderItem = ({ item, index, type, ...restArgs }) => {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} param0
|
||||
* @returns
|
||||
*/
|
||||
const List = ({
|
||||
listData,
|
||||
type,
|
||||
@@ -93,23 +101,34 @@ const List = ({
|
||||
},
|
||||
screen,
|
||||
ListHeader,
|
||||
warning
|
||||
warning,
|
||||
isSheet = false,
|
||||
onMomentumScrollEnd
|
||||
}) => {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const scrollRef = useRef();
|
||||
const [notesListMode, notebooksListMode] = useSettingStore((state) => [
|
||||
state.settings.notesListMode,
|
||||
state.settings.notebooksListMode
|
||||
]);
|
||||
const isCompactModeEnabled =
|
||||
(type === "notes" && notesListMode === "compact") ||
|
||||
type === "notebooks" ||
|
||||
notebooksListMode === "compact";
|
||||
|
||||
const renderItem = React.useCallback(
|
||||
({ item, index }) => (
|
||||
<RenderItem
|
||||
item={item}
|
||||
index={index}
|
||||
color={headerProps.color}
|
||||
title={headerProps.heading}
|
||||
color={headerProps?.color}
|
||||
title={headerProps?.heading}
|
||||
type={screen === "Notes" ? "home" : type}
|
||||
screen={screen}
|
||||
isSheet={isSheet}
|
||||
/>
|
||||
),
|
||||
[headerProps.color, headerProps.heading, screen, type]
|
||||
[headerProps?.color, headerProps?.heading, screen, type, isSheet]
|
||||
);
|
||||
|
||||
const _onRefresh = async () => {
|
||||
@@ -148,20 +167,21 @@ const List = ({
|
||||
}}
|
||||
entering={type === "search" ? undefined : FadeInDown}
|
||||
>
|
||||
<FlatList
|
||||
<FlashList
|
||||
style={styles}
|
||||
keyExtractor={_keyExtractor}
|
||||
ref={scrollRef}
|
||||
testID={notesnook.list.id}
|
||||
data={listData}
|
||||
renderItem={renderItem}
|
||||
onScroll={_onScroll}
|
||||
windowSize={5}
|
||||
nestedScrollEnabled={true}
|
||||
onMomentumScrollEnd={() => {
|
||||
tabBarRef.current?.unlock();
|
||||
onMomentumScrollEnd?.();
|
||||
}}
|
||||
getItemType={(item) => item.itemType || item.type}
|
||||
estimatedItemSize={isCompactModeEnabled ? 60 : 100}
|
||||
directionalLockEnabled={true}
|
||||
initialNumToRender={10}
|
||||
keyboardShouldPersistTaps="always"
|
||||
keyboardDismissMode="interactive"
|
||||
refreshControl={
|
||||
@@ -174,20 +194,22 @@ const List = ({
|
||||
/>
|
||||
}
|
||||
ListEmptyComponent={
|
||||
<Empty
|
||||
loading={loading}
|
||||
placeholderData={placeholderData}
|
||||
headerProps={headerProps}
|
||||
type={type}
|
||||
screen={screen}
|
||||
/>
|
||||
placeholderData ? (
|
||||
<Empty
|
||||
loading={loading}
|
||||
placeholderData={placeholderData}
|
||||
headerProps={headerProps}
|
||||
type={type}
|
||||
screen={screen}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
ListFooterComponent={<Footer />}
|
||||
ListHeaderComponent={
|
||||
<>
|
||||
{ListHeader ? (
|
||||
ListHeader
|
||||
) : (
|
||||
) : !headerProps ? null : (
|
||||
<Header
|
||||
title={headerProps.heading}
|
||||
color={headerProps.color}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -115,8 +115,10 @@ export default function NoteHistory({ note, fwdRef }) {
|
||||
style={{
|
||||
paddingHorizontal: 12
|
||||
}}
|
||||
nestedScrollEnabled
|
||||
keyExtractor={(item) => item.id}
|
||||
data={history}
|
||||
ListFooterComponent={<View style={{ height: 250 }} />}
|
||||
ListEmptyComponent={
|
||||
<View
|
||||
style={{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -26,18 +26,42 @@ import { editorController } from "../../screens/editor/tiptap/utils";
|
||||
import { eSendEvent, ToastEvent } from "../../services/event-manager";
|
||||
import Navigation from "../../services/navigation";
|
||||
import { useEditorStore } from "../../stores/use-editor-store";
|
||||
import { useSelectionStore } from "../../stores/use-selection-store";
|
||||
import { useThemeStore } from "../../stores/use-theme-store";
|
||||
import { eCloseProgressDialog, eOnLoadNote } from "../../utils/events";
|
||||
import { useTrashStore } from "../../stores/use-trash-store";
|
||||
import { eCloseSheet, eOnLoadNote } from "../../utils/events";
|
||||
import { sleep } from "../../utils/time";
|
||||
import { Dialog } from "../dialog";
|
||||
import DialogHeader from "../dialog/dialog-header";
|
||||
import { presentDialog } from "../dialog/functions";
|
||||
import { Button } from "../ui/button";
|
||||
import Paragraph from "../ui/typography/paragraph";
|
||||
|
||||
export default function NotePreview({ session, content }) {
|
||||
export default function NotePreview({ session, content, note }) {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
const editorId = ":noteHistory";
|
||||
|
||||
async function restore() {
|
||||
if (note && note.type === "trash") {
|
||||
await db.trash.restore(note.id);
|
||||
Navigation.queueRoutesForUpdate(
|
||||
"Tags",
|
||||
"Notes",
|
||||
"Notebooks",
|
||||
"Favorites",
|
||||
"Trash",
|
||||
"TaggedNotes",
|
||||
"ColoredNotes",
|
||||
"TopicNotes"
|
||||
);
|
||||
useSelectionStore.getState().setSelectionMode(false);
|
||||
ToastEvent.show({
|
||||
heading: "Restore successful",
|
||||
type: "success"
|
||||
});
|
||||
eSendEvent(eCloseSheet);
|
||||
return;
|
||||
}
|
||||
await db.noteHistory.restore(session.id);
|
||||
if (useEditorStore.getState()?.currentEditingNote === session?.noteId) {
|
||||
if (editorController.current?.note) {
|
||||
@@ -47,8 +71,8 @@ export default function NotePreview({ session, content }) {
|
||||
});
|
||||
}
|
||||
}
|
||||
eSendEvent(eCloseProgressDialog, "note_history");
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
eSendEvent(eCloseSheet, "note_history");
|
||||
eSendEvent(eCloseSheet);
|
||||
Navigation.queueRoutesForUpdate(
|
||||
"Notes",
|
||||
"Favorites",
|
||||
@@ -63,15 +87,38 @@ export default function NotePreview({ session, content }) {
|
||||
});
|
||||
}
|
||||
|
||||
const deleteNote = async () => {
|
||||
presentDialog({
|
||||
title: `Delete note permanently`,
|
||||
paragraph: `Are you sure you want to delete this note from trash permanentaly`,
|
||||
positiveText: "Delete",
|
||||
negativeText: "Cancel",
|
||||
context: "local",
|
||||
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"
|
||||
});
|
||||
eSendEvent(eCloseSheet);
|
||||
},
|
||||
positiveType: "error"
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
height: session.locked ? null : 600,
|
||||
height: note?.locked || session?.locked ? null : 600,
|
||||
width: "100%"
|
||||
}}
|
||||
>
|
||||
<DialogHeader padding={12} title={session.session} />
|
||||
{!session.locked ? (
|
||||
<Dialog context="local" />
|
||||
<DialogHeader padding={12} title={note?.title || session?.session} />
|
||||
{!session?.locked && !note?.locked ? (
|
||||
<View
|
||||
style={{
|
||||
flex: 1
|
||||
@@ -84,10 +131,10 @@ export default function NotePreview({ session, content }) {
|
||||
readonly
|
||||
editorId={editorId}
|
||||
onLoad={async () => {
|
||||
const note = db.notes.note(session.noteId)?.data;
|
||||
await sleep(300);
|
||||
const _note = note || db.notes.note(session?.noteId)?.data;
|
||||
await sleep(1000);
|
||||
eSendEvent(eOnLoadNote + editorId, {
|
||||
...note,
|
||||
..._note,
|
||||
content: {
|
||||
...content,
|
||||
isPreview: true
|
||||
@@ -116,11 +163,15 @@ export default function NotePreview({ session, content }) {
|
||||
paddingHorizontal: 12
|
||||
}}
|
||||
>
|
||||
<Button onPress={restore} title="Restore" type="accent" width="100%" />
|
||||
<Button
|
||||
onPress={restore}
|
||||
title="Restore this version"
|
||||
type="accent"
|
||||
onPress={deleteNote}
|
||||
title="Delete permanently"
|
||||
type="error"
|
||||
width="100%"
|
||||
style={{
|
||||
marginTop: 12
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -55,6 +55,11 @@ export const CompactFeatures = ({
|
||||
content: "vault",
|
||||
icon: "shield"
|
||||
},
|
||||
{
|
||||
highlight: "Daily, weekly & montly",
|
||||
content: "recurring reminders",
|
||||
icon: "bell"
|
||||
},
|
||||
{
|
||||
highlight: "Rich text",
|
||||
content: "editing",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -30,7 +30,7 @@ import { useUserStore } from "../../stores/use-user-store";
|
||||
import { getElevation } from "../../utils";
|
||||
import {
|
||||
eClosePremiumDialog,
|
||||
eCloseProgressDialog,
|
||||
eCloseSheet,
|
||||
eOpenLoginDialog
|
||||
} from "../../utils/events";
|
||||
import { SIZE } from "../../utils/size";
|
||||
@@ -48,7 +48,7 @@ import { Walkthrough } from "../walkthroughs";
|
||||
import { features } from "./features";
|
||||
import { Group } from "./group";
|
||||
import { PricingPlans } from "./pricing-plans";
|
||||
import { Platform } from 'react-native';
|
||||
import { Platform } from "react-native";
|
||||
|
||||
export const Component = ({ close, promo }) => {
|
||||
const colors = useThemeStore((state) => state.colors);
|
||||
@@ -194,7 +194,7 @@ export const Component = ({ close, promo }) => {
|
||||
try {
|
||||
await db.user.activateTrial();
|
||||
eSendEvent(eClosePremiumDialog);
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
eSendEvent(eCloseSheet);
|
||||
await sleep(300);
|
||||
Walkthrough.present("trialstarted", false, true);
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
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
|
||||
@@ -71,8 +71,7 @@ export const FeatureBlock = ({
|
||||
<Icon color={colors.icon} name={icon} size={SIZE.xl} />
|
||||
<Paragraph size={SIZE.md}>
|
||||
<Text style={{ color: colors.accent }}>{highlight}</Text>
|
||||
{"\n"}
|
||||
{content}
|
||||
{content ? "\n" + content : null}
|
||||
</Paragraph>
|
||||
|
||||
{pro ? (
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user