Skip to content

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

web: inbox UI fixes * use user format preferences for dates in inbox module * delete all failed inbox items when inbox is disabled * improve error message for failed validation case

01zulfi7deb095aca99
diff --git a/apps/web/src/dialogs/InboxHistoryDialog.tsx b/apps/web/src/dialogs/InboxHistoryDialog.tsx
index f2fc7a780..5093361b5 100644
--- a/apps/web/src/dialogs/InboxHistoryDialog.tsx
+++ b/apps/web/src/dialogs/InboxHistoryDialog.tsx
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useState } from "react";
-import { usePromise } from "@notesnook/common";
-import { formatDate, InboxItemsHistoryErrorContext } from "@notesnook/core";
+import { getFormattedDate, usePromise } from "@notesnook/common";
+import { InboxItemsHistoryErrorContext } from "@notesnook/core";
import { Box, Button, Text } from "@theme-ui/components";
import { db } from "../common/db";
import { BaseDialogProps, DialogManager } from "../common/dialog-manager";
@@ -30,6 +30,7 @@ import ScrollContainer, {
} from "../components/scroll-container";
import { strings } from "@notesnook/intl";
import { writeText } from "clipboard-polyfill";
+import { showToast } from "../utils/toast";
type InboxHistoryDialogProps = BaseDialogProps<boolean>;
@@ -152,6 +153,7 @@ export const InboxHistoryDialog = DialogManager.register(
async function deleteItem(id: string) {
await db.inboxItemsHistory.delete(id);
+ showToast("success", strings.itemDeleted());
if (result.status !== "pending") {
result.refresh();
}
@@ -218,7 +220,7 @@ export const InboxHistoryDialog = DialogManager.register(
<Box as="tr" key={item.id}>
<Box as="td">
<Text variant="body" sx={{ whiteSpace: "nowrap" }}>
- {formatDate(item.dateSynced)}
+ {getFormattedDate(item.dateSynced)}
</Text>
</Box>
<Box as="td">
diff --git a/apps/web/src/dialogs/settings/components/inbox-api-keys.tsx b/apps/web/src/dialogs/settings/components/inbox-api-keys.tsx
index 3206a83ec..2a770aea8 100644
--- a/apps/web/src/dialogs/settings/components/inbox-api-keys.tsx
+++ b/apps/web/src/dialogs/settings/components/inbox-api-keys.tsx
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { useRef, useState, useEffect } from "react";
import { Box, Button, Flex, Input, Text, Select } from "@theme-ui/components";
-import { formatDate, InboxApiKey } from "@notesnook/core";
+import { InboxApiKey } from "@notesnook/core";
import { db } from "../../../common/db";
import { showToast } from "../../../utils/toast";
import {
@@ -32,7 +32,7 @@ import {
import Field from "../../../components/field";
import { BaseDialogProps, DialogManager } from "../../../common/dialog-manager";
import Dialog from "../../../components/dialog";
-import { usePromise } from "@notesnook/common";
+import { getFormattedDate, usePromise } from "@notesnook/common";
import { ConfirmDialog } from "../../confirm";
import { showPasswordDialog } from "../../password-dialog";
import { strings } from "@notesnook/intl";
@@ -233,17 +233,17 @@ function ApiKeyItem({ apiKey, onRevoke, isAtEnd }: ApiKeyItemProps) {
<Flex sx={{ mb: 1, flexDirection: "column" }}>
<Text variant="subBody" sx={{ color: "paragraph-secondary" }}>
{apiKey.lastUsedAt
- ? `Last used on ${formatDate(apiKey.lastUsedAt)}`
+ ? `Last used on ${getFormattedDate(apiKey.lastUsedAt)}`
: "Never used"}
</Text>
<Text variant="subBody" sx={{ color: "paragraph-secondary" }}>
- Created on {formatDate(apiKey.dateCreated)}
+ Created on {getFormattedDate(apiKey.dateCreated)}
</Text>
<Text variant="subBody" sx={{ color: "paragraph-secondary" }}>
{apiKey.expiryDate === -1
? "Never expires"
: `${isApiKeyExpired ? "Expired" : "Expires"} on
- ${formatDate(apiKey.expiryDate)}`}
+ ${getFormattedDate(apiKey.expiryDate)}`}
</Text>
</Flex>
</Box>
diff --git a/apps/web/src/stores/setting-store.ts b/apps/web/src/stores/setting-store.ts
index c7230a524..b0d0fa10d 100644
--- a/apps/web/src/stores/setting-store.ts
+++ b/apps/web/src/stores/setting-store.ts
@@ -305,6 +305,7 @@ class SettingStore extends BaseStore<SettingStore> {
});
if (!ok) return;
+ await db.inboxItemsHistory.deleteFailed();
await db.user.discardInboxKeys();
this.set({ isInboxEnabled: false });
diff --git a/packages/core/src/api/sync/merger.ts b/packages/core/src/api/sync/merger.ts
index 60cbb4366..bc5441d88 100644
--- a/packages/core/src/api/sync/merger.ts
+++ b/packages/core/src/api/sync/merger.ts
@@ -266,7 +266,7 @@ export async function handleInboxItems(
errorContext: JSON.stringify({
message: "Validation failed",
description: validation.error.issues
- .map((i) => i.message)
+ .map((i) => `${i.path.join(".")}: ${i.message}`)
.join("; "),
inboxItem: { id: item.id, v: item.v, alg: item.alg },
parsedItem: parsedWithoutContent
diff --git a/packages/core/src/collections/inbox-items-history.ts b/packages/core/src/collections/inbox-items-history.ts
index c93cc5b3a..9d72c3b5a 100644
--- a/packages/core/src/collections/inbox-items-history.ts
+++ b/packages/core/src/collections/inbox-items-history.ts
@@ -71,6 +71,11 @@ export class InboxItemsHistory implements ICollection {
await this.collection.softDelete([id]);
}
+ async deleteFailed() {
+ const ids = await this.failed.ids();
+ await this.collection.softDelete(ids);
+ }
+
exists(id: string) {
return this.collection.exists(id);
}
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 3dd7a2fb3..36a4620d6 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -3676,6 +3676,10 @@ msgstr "item"
msgid "Item"
msgstr "Item"
+#: src/strings.ts:2734
+msgid "Item deleted"
+msgstr "Item deleted"
+
#: src/strings.ts:311
#: src/strings.ts:1705
msgid "items"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index ae4c03c68..c0ac36fc2 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -3656,6 +3656,10 @@ msgstr ""
msgid "Item"
msgstr ""
+#: src/strings.ts:2734
+msgid "Item deleted"
+msgstr ""
+
#: src/strings.ts:311
#: src/strings.ts:1705
msgid "items"
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index eced6fba2..960f68e57 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2750,5 +2750,6 @@ Continue without attachments?`,
failedInboxItems: () => t`Failed inbox items`,
failedInboxItemsDesc: () => t`View failed inbox items and error contexts`,
noFailedInboxItems: () => t`No failed inbox items`,
- show: () => t`Show`
+ show: () => t`Show`,
+ itemDeleted: () => t`Item deleted`
};