Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: re-enable reminders

thecodrr1b12271679f4
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index 3c65eca9a..bee00cfe3 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -1,3 +1,4 @@
+import React from "react";
import StorageInterface from "../interfaces/storage";
import Database from "notes-core/api/";
import SelectionOptions from "./selectionoptions";
@@ -7,6 +8,11 @@ import { store as editorStore } from "../stores/editor-store";
import { store as noteStore } from "../stores/note-store";
import { showAddNotebookDialog } from "../components/dialogs/addnotebookdialog";
import { showTopicDialog } from "../components/dialogs/topicdialog";
+import { showToast } from "../utils/toast";
+import download from "../utils/download";
+import { Text } from "rebass";
+import { showLoadingDialog } from "../components/dialogs/loadingdialog";
+import Config from "../utils/config";
export const db = new Database(StorageInterface, EventSource);
db.host("http://localhost:4100");
@@ -71,3 +77,25 @@ export function notesFromContext(context) {
}
return notes;
}
+
+export async function createBackup() {
+ const encryptBackups = Config.get("encryptBackups", false);
+ const data = await showLoadingDialog({
+ title: "Creating backup",
+ subtitle: "We are creating a backup of your data. Please wait...",
+ action: async () => {
+ return await db.backup.export("web", encryptBackups);
+ },
+ message: (
+ <Text color="error">
+ Please do NOT close your browser or shut down your PC.
+ </Text>
+ ),
+ });
+ download(
+ `notesnook-backup-${new Date().toLocaleString("en")}`,
+ data,
+ "nnbackup"
+ );
+ await showToast("success", "Backup created!");
+}
diff --git a/apps/web/src/common/reminders.js b/apps/web/src/common/reminders.js
index 1fbcf3438..b251d0d62 100644
--- a/apps/web/src/common/reminders.js
+++ b/apps/web/src/common/reminders.js
@@ -1,13 +1,12 @@
import Config from "../utils/config";
-import { db } from "./index";
+import { createBackup, db } from "./index";
import * as Icon from "../components/icons";
import dayjs from "dayjs";
import { showSignUpDialog } from "../components/dialogs/signupdialog";
-import download from "../utils/download";
export async function shouldAddBackupReminder() {
const backupReminderOffset = Config.get("backupReminderOffset", 0);
- if (backupReminderOffset) return false;
+ if (!backupReminderOffset) return false;
const lastBackupTime = await db.backup.lastBackupTime();
const offsetToDays =
@@ -23,24 +22,12 @@ export async function shouldAddSignupReminder() {
export const Reminders = {
backup: {
title: "Back up your data now!",
- action: {
- text: "Click here to backup!",
- onClick: async () => {
- download(
- `notesnook-backup-${new Date().toLocaleString("en")}`,
- await db.backup.export(),
- "nnbackup"
- );
- },
- },
+ action: createBackup,
icon: Icon.Backup,
},
signup: {
- title: "Sign up for cross-device syncing and so much more!",
- action: {
- text: "Click here to sign up!",
- onClick: () => showSignUpDialog(),
- },
- icon: Icon.User,
+ title: "Sign up for cross-device syncing!",
+ action: async () => showSignUpDialog(),
+ icon: Icon.Login,
},
};
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 0ef35ada5..e1e3b078f 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -8,6 +8,7 @@ import { useStore as useSelectionStore } from "../../stores/selection-store";
import GroupHeader from "../group-header";
import ListProfiles from "../../common/list-profiles";
import ScrollContainer from "../scroll-container";
+import ReminderBar from "../reminder-bar";
const CustomScrollbarsVirtualList = React.forwardRef((props, ref) => (
<ScrollContainer {...props} forwardedRef={ref} />
@@ -42,6 +43,7 @@ function ListContainer(props) {
</Flex>
) : (
<>
+ <ReminderBar />
<Flex variant="columnFill" data-test-id="note-list">
{props.children
? props.children
diff --git a/apps/web/src/components/reminder-bar/index.js b/apps/web/src/components/reminder-bar/index.js
index 347569d47..207850813 100644
--- a/apps/web/src/components/reminder-bar/index.js
+++ b/apps/web/src/components/reminder-bar/index.js
@@ -1,38 +1,36 @@
import React, { useMemo } from "react";
-import { Flex, Text, Box } from "rebass";
+import { Flex, Text } from "rebass";
import { useStore as useAppStore } from "../../stores/app-store";
import { Reminders } from "../../common/reminders";
+import * as Icon from "../icons";
function ReminderBar() {
const reminders = useAppStore((store) => store.reminders);
const reminder = useMemo(() => {
- const reminder = reminders.sort((a, b) => a.priority - b.priority)[0];
+ const copy = reminders.slice();
+ const reminder = copy.sort((a, b) => a.priority - b.priority)[0];
if (!reminder) return;
return Reminders[reminder.type];
}, [reminders]);
if (!reminder) return null;
return (
<Flex
- height={65}
- p={2}
- mt={2}
+ p={1}
bg={"shade"}
alignItems="center"
mx={2}
+ mb={1}
sx={{ cursor: "pointer", borderRadius: "default" }}
- onClick={reminder?.action?.onClick}
+ onClick={reminder?.action}
+ justifyContent="space-between"
>
- <Box sx={{ bg: "primary", borderRadius: 80 }} width={40} p={2} mr={2}>
- <reminder.icon size={18} color="static" />
- </Box>
- <Flex flexDirection="column">
- <Text variant="subBody" fontSize={10}>
- {reminder.action.text}
- </Text>
+ <Flex>
+ <reminder.icon size={14} color="primary" sx={{ mr: 1 }} />
<Text variant="subBody" fontSize={10} color="primary">
{reminder.title}
</Text>
</Flex>
+ <Icon.ArrowRight size={14} color="primary" />
</Flex>
);
}
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 571f2ddab..4f1e01a35 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -9,8 +9,7 @@ import accents from "../theme/accents";
import { showLogInDialog } from "../components/dialogs/logindialog";
import { showLogoutConfirmation } from "../components/dialogs/confirm";
import useSystemTheme from "../utils/use-system-theme";
-import download from "../utils/download";
-import { db, SUBSCRIPTION_STATUS } from "../common";
+import { createBackup, db, SUBSCRIPTION_STATUS } from "../common";
import { usePersistentState } from "../utils/hooks";
import dayjs from "dayjs";
import { showRecoveryKeyDialog } from "../components/dialogs/recoverykeydialog";
@@ -245,29 +244,7 @@ function Settings(props) {
>
{"Backup & Restore"}
</Text>
- <Button
- variant="list"
- onClick={async () => {
- const data = await showLoadingDialog({
- title: "Creating backup",
- subtitle: "We are creating a backup of your data. Please wait...",
- action: async () => {
- return await db.backup.export("web", encryptBackups);
- },
- message: (
- <Text color="error">
- Please do NOT close your browser or shut down your PC.
- </Text>
- ),
- });
- download(
- `notesnook-backup-${new Date().toLocaleString("en")}`,
- data,
- "nnbackup"
- );
- await showToast("success", "Backup created!");
- }}
- >
+ <Button variant="list" onClick={createBackup}>
<TextWithTip
text="Backup data"
tip="Backup and download all your data"
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index 280fe9659..e67641251 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8964,7 +8964,7 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
"notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":
version "2.6.2"
- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#423d4f84f61013cea247a4c2b6aa6ee428602531"
+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#26decb520d853e8c1724a18f4652d0791eb30e91"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"