@remit/web-client 0.0.194 → 0.0.196

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.
@@ -2,11 +2,8 @@ import type {
2
2
  RemitImapFolderAppointment,
3
3
  RemitImapMailboxResponse,
4
4
  } from "@remit/api-http-client/types.gen.ts";
5
- import {
6
- buildMailboxRoleMap,
7
- getMailboxDisplayName,
8
- ROLE_PRIORITY,
9
- } from "./folder-roles.js";
5
+ import { mailboxLeafName } from "@remit/data-ports/mailbox-name";
6
+ import { buildMailboxRoleMap, ROLE_PRIORITY } from "./folder-roles.js";
10
7
 
11
8
  // Outbox has no IMAP special-use flag (RFC 6154 doesn't define one) and isn't
12
9
  // a canonical role (RFC 032 exclusive-folder-appointment) either — it's
@@ -27,7 +24,7 @@ const OUTBOX_LOCALE_NAMES: ReadonlySet<string> = new Set([
27
24
  ]);
28
25
 
29
26
  const isOutboxDestination = (mailbox: RemitImapMailboxResponse): boolean => {
30
- const leaf = getMailboxDisplayName(mailbox.fullPath).trim().toLowerCase();
27
+ const leaf = mailboxLeafName(mailbox).trim().toLowerCase();
31
28
  return OUTBOX_LOCALE_NAMES.has(leaf);
32
29
  };
33
30
 
@@ -65,10 +62,9 @@ export const buildMoveTargets = (
65
62
  ? ROLE_PRIORITY.indexOf(roleMap.get(b.mailboxId) ?? "inbox")
66
63
  : NON_SYSTEM_PRIORITY;
67
64
  if (aPriority !== bPriority) return aPriority - bPriority;
68
- return getMailboxDisplayName(a.fullPath).localeCompare(
69
- getMailboxDisplayName(b.fullPath),
70
- undefined,
71
- { sensitivity: "base", numeric: true },
72
- );
65
+ return mailboxLeafName(a).localeCompare(mailboxLeafName(b), undefined, {
66
+ sensitivity: "base",
67
+ numeric: true,
68
+ });
73
69
  });
74
70
  };
@@ -209,3 +209,32 @@ describe("buildAccountSuggestionValues", () => {
209
209
  );
210
210
  });
211
211
  });
212
+
213
+ describe("the server’s own delimiter (#877)", () => {
214
+ it("offers the leaf of a dot-delimited folder as its shortest spelling", () => {
215
+ const values = buildMailboxSuggestionValues([
216
+ [
217
+ mailbox({
218
+ mailboxId: "m1",
219
+ fullPath: "INBOX.Projects.Q3",
220
+ hierarchyDelimiter: ".",
221
+ }),
222
+ ],
223
+ ]);
224
+ assert.deepEqual(values, [{ value: "Q3", label: "Q3" }]);
225
+ });
226
+
227
+ it("resolves in: by the leaf of a dot-delimited folder", () => {
228
+ const index = buildMailboxNameIndex([
229
+ [
230
+ mailbox({
231
+ mailboxId: "m1",
232
+ fullPath: "INBOX.Projects.Q3",
233
+ hierarchyDelimiter: ".",
234
+ }),
235
+ ],
236
+ ]);
237
+ assert.equal(index.get("q3"), "m1");
238
+ assert.equal(index.get("inbox.projects.q3"), "m1");
239
+ });
240
+ });
@@ -13,7 +13,7 @@ import type {
13
13
  RemitImapAccountResponse,
14
14
  RemitImapMailboxResponse,
15
15
  } from "@remit/api-http-client/types.gen.ts";
16
- import { getMailboxDisplayName } from "./folder-roles.js";
16
+ import { mailboxLeafName } from "@remit/data-ports/mailbox-name";
17
17
  import type { SearchSuggestionValue } from "./search-suggestions.js";
18
18
 
19
19
  /**
@@ -52,11 +52,9 @@ export function buildMailboxNameIndex(
52
52
  for (const mailbox of mailboxes) {
53
53
  const fullPath = mailbox.fullPath?.toLowerCase();
54
54
  if (!fullPath) continue;
55
- const lastSegment = fullPath.split("/").pop();
55
+ const leaf = mailboxLeafName(mailbox).toLowerCase();
56
56
  if (!index.has(fullPath)) index.set(fullPath, mailbox.mailboxId);
57
- if (lastSegment && !index.has(lastSegment)) {
58
- index.set(lastSegment, mailbox.mailboxId);
59
- }
57
+ if (!index.has(leaf)) index.set(leaf, mailbox.mailboxId);
60
58
  }
61
59
  }
62
60
  return index;
@@ -78,14 +76,14 @@ export function buildMailboxSuggestionValues(
78
76
  const all = mailboxesByAccount.flat().filter((mailbox) => mailbox.fullPath);
79
77
  const leafCounts = new Map<string, number>();
80
78
  for (const mailbox of all) {
81
- const leaf = getMailboxDisplayName(mailbox.fullPath).toLowerCase();
79
+ const leaf = mailboxLeafName(mailbox).toLowerCase();
82
80
  leafCounts.set(leaf, (leafCounts.get(leaf) ?? 0) + 1);
83
81
  }
84
82
  const emailByAccountId = new Map(
85
83
  accounts.map((account) => [account.accountId, account.email]),
86
84
  );
87
85
  return all.map((mailbox) => {
88
- const leaf = getMailboxDisplayName(mailbox.fullPath);
86
+ const leaf = mailboxLeafName(mailbox);
89
87
  const unique = leafCounts.get(leaf.toLowerCase()) === 1;
90
88
  const hint =
91
89
  accounts.length > 1 ? emailByAccountId.get(mailbox.accountId) : undefined;
@@ -166,6 +166,7 @@ function AccountFolders({ account }: { account: RemitImapAccountResponse }) {
166
166
  const candidates: CandidateFolder[] = mailboxes.map((mailbox) => ({
167
167
  mailboxId: mailbox.mailboxId,
168
168
  providerPath: mailbox.fullPath,
169
+ hierarchyDelimiter: mailbox.hierarchyDelimiter,
169
170
  messageCount: mailbox.messageCount,
170
171
  }));
171
172
 
@@ -241,7 +242,10 @@ function AccountFolders({ account }: { account: RemitImapAccountResponse }) {
241
242
  translator,
242
243
  )}
243
244
  defaultLabel={labelForMailbox(
244
- { fullPath: renaming.fullPath },
245
+ {
246
+ fullPath: renaming.fullPath,
247
+ hierarchyDelimiter: renaming.hierarchyDelimiter,
248
+ },
245
249
  roleMap.get(renaming.mailboxId),
246
250
  translator,
247
251
  )}