@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.
- package/package.json +2 -1
- package/src/components/settings/DeleteFolderDialog.render.test.ts +220 -5
- package/src/components/settings/DeleteFolderDialog.tsx +90 -13
- package/src/hooks/useAutoMovedBadge.ts +2 -2
- package/src/hooks/useCreateMailbox.render.test.ts +2 -0
- package/src/hooks/useCreateMailbox.ts +2 -2
- package/src/hooks/useDeleteFolder.ts +113 -0
- package/src/lib/delete-folder.test.ts +14 -0
- package/src/lib/delete-folder.ts +6 -0
- package/src/lib/folder-roles.test.ts +59 -16
- package/src/lib/folder-roles.ts +6 -8
- package/src/lib/fresh-mailbox-count.test.ts +145 -0
- package/src/lib/fresh-mailbox-count.ts +114 -0
- package/src/lib/mailbox-sync-wait.ts +6 -2
- package/src/lib/move-targets.test.ts +19 -0
- package/src/lib/move-targets.ts +7 -11
- package/src/lib/search-token-index.test.ts +29 -0
- package/src/lib/search-token-index.ts +5 -7
- package/src/routes/settings/folders.tsx +5 -1
package/src/lib/move-targets.ts
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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 {
|
|
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
|
|
55
|
+
const leaf = mailboxLeafName(mailbox).toLowerCase();
|
|
56
56
|
if (!index.has(fullPath)) index.set(fullPath, mailbox.mailboxId);
|
|
57
|
-
if (
|
|
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 =
|
|
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 =
|
|
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
|
-
{
|
|
245
|
+
{
|
|
246
|
+
fullPath: renaming.fullPath,
|
|
247
|
+
hierarchyDelimiter: renaming.hierarchyDelimiter,
|
|
248
|
+
},
|
|
245
249
|
roleMap.get(renaming.mailboxId),
|
|
246
250
|
translator,
|
|
247
251
|
)}
|