@remit/web-client 0.0.299 → 0.0.300

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client",
3
- "version": "0.0.299",
3
+ "version": "0.0.300",
4
4
  "type": "module",
5
5
  "description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
6
6
  "exports": {
@@ -12,6 +12,7 @@ import { NavSidebar } from "@remit/ui";
12
12
  import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
13
13
  import { useCallback, useMemo } from "react";
14
14
  import { useTranslation } from "react-i18next";
15
+ import { folderFailure } from "@/lib/folder-failure";
15
16
  import {
16
17
  buildMailboxRoleMap,
17
18
  labelForMailbox,
@@ -103,6 +104,7 @@ function toNavMailbox(
103
104
  unseen: showBadge ? mb.unseenCount : undefined,
104
105
  role,
105
106
  fullPath: mb.fullPath,
107
+ failure: folderFailure(mb),
106
108
  };
107
109
  }
108
110
 
@@ -0,0 +1,29 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import { folderFailure } from "./folder-failure.js";
4
+
5
+ describe("folderFailure", () => {
6
+ it("says nothing about a folder that did not fail", () => {
7
+ assert.equal(
8
+ folderFailure({ syncStatus: "synced", syncFailureReason: "" }),
9
+ undefined,
10
+ );
11
+ });
12
+
13
+ it("carries the mail server's own words", () => {
14
+ assert.equal(
15
+ folderFailure({
16
+ syncStatus: "failed",
17
+ syncFailureReason: "Permission denied",
18
+ }),
19
+ "The mail server refused the last change: Permission denied",
20
+ );
21
+ });
22
+
23
+ it("still says it failed when the server gave no reason", () => {
24
+ assert.equal(
25
+ folderFailure({ syncStatus: "failed", syncFailureReason: " " }),
26
+ "The last change to this folder failed.",
27
+ );
28
+ });
29
+ });
@@ -0,0 +1,10 @@
1
+ import type { RemitImapMailboxResponse } from "@remit/api-http-client/types.gen.ts";
2
+
3
+ export const folderFailure = (
4
+ mailbox: Pick<RemitImapMailboxResponse, "syncStatus" | "syncFailureReason">,
5
+ ): string | undefined => {
6
+ if (mailbox.syncStatus !== "failed") return undefined;
7
+ const reason = mailbox.syncFailureReason.trim();
8
+ if (reason.length === 0) return "The last change to this folder failed.";
9
+ return `The mail server refused the last change: ${reason}`;
10
+ };
@@ -32,6 +32,7 @@ import { useCreateMailbox } from "@/hooks/useCreateMailbox";
32
32
  import { useFolderLabelTranslator } from "@/hooks/useFolderLabelTranslator";
33
33
  import { guardFolderDeletion } from "@/lib/delete-folder";
34
34
  import { softErrorStatuses } from "@/lib/error-classifier";
35
+ import { folderFailure } from "@/lib/folder-failure";
35
36
  import {
36
37
  buildMailboxRoleMap,
37
38
  CANONICAL_TO_NAV_ROLE,
@@ -104,6 +105,7 @@ function AccountFolders({ account }: { account: RemitImapAccountResponse }) {
104
105
  mailboxes,
105
106
  account.folderAppointments,
106
107
  ).message,
108
+ failure: folderFailure(mailbox),
107
109
  })),
108
110
  [mailboxes, roleMap, translator, account.folderAppointments],
109
111
  );
@@ -28,6 +28,7 @@ export const makeMailbox = (
28
28
  highWaterMarkUid: 0,
29
29
  lastMessageSyncAt: 0,
30
30
  syncStatus: "synced",
31
+ syncFailureReason: "",
31
32
  createdAt: 0,
32
33
  updatedAt: 0,
33
34
  ...overrides,