@remit/web-client 0.0.311 → 0.0.313
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 +1 -1
- package/src/components/compose/ComposeForm.tsx +76 -13
- package/src/components/compose/ComposeProvider.tsx +35 -1
- package/src/components/compose/ConversationCompose.tsx +19 -0
- package/src/components/compose/compose-inline-image.render.test.ts +542 -0
- package/src/components/compose/compose.stories.tsx +13 -0
- package/src/components/compose/reply-with-times.ts +22 -0
- package/src/components/mail/BriefPane.tsx +7 -0
- package/src/components/mail/FlaggedPane.tsx +7 -0
- package/src/components/mail/IntelligenceDrawer.tsx +4 -0
- package/src/components/mail/IntelligencePane.tsx +7 -1
- package/src/components/mail/MailboxPane.tsx +7 -0
- package/src/components/mail/offer-times-reply.render.test.ts +529 -0
- package/src/hooks/intelligence-calendar.render.test.ts +0 -19
- package/src/hooks/useComposeAttachments.ts +6 -1
- package/src/hooks/useInlineImages.ts +93 -0
- package/src/hooks/useIntelligenceCalendar.ts +8 -19
- package/src/lib/compose-attachment-controller.test.ts +110 -0
- package/src/lib/compose-attachment-controller.ts +120 -16
- package/src/lib/mail-search.ts +17 -0
- package/src/routes/mail/$mailboxId/$threadId/$messageId/$mode.{-$outboxMessageId}.tsx +2 -1
- package/src/routes/mail/brief/$threadId/$messageId/$mode.{-$outboxMessageId}.tsx +2 -1
- package/src/routes/mail/flagged/$threadId/$messageId/$mode.{-$outboxMessageId}.tsx +2 -1
- package/src/routing/compose.ts +2 -1
- package/src/routing/outbox-draft.ts +2 -1
- package/src/routing/reply.ts +34 -8
package/src/routing/reply.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useNavigate, useParams } from "@tanstack/react-router";
|
|
1
|
+
import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import type { MailListRoute } from "@/lib/mail-route";
|
|
5
|
+
import { type ComposeSeed, withoutComposeSeed } from "@/lib/mail-search";
|
|
5
6
|
import { useBrowsedList } from "./browsed-list";
|
|
6
7
|
import { useRetainOpenPanels } from "./fragment";
|
|
7
8
|
|
|
@@ -53,6 +54,7 @@ export interface ReplyAddress {
|
|
|
53
54
|
sourceMessageId: string;
|
|
54
55
|
/** The draft it writes to, once the first autosave has made one. */
|
|
55
56
|
outboxMessageId: string | undefined;
|
|
57
|
+
seed: ComposeSeed | undefined;
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export type ReplySurface =
|
|
@@ -79,6 +81,20 @@ function useReplyParams(): ReplyParams | undefined {
|
|
|
79
81
|
return brief ?? flagged ?? mailbox;
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
function useReplySeed(): string | undefined {
|
|
85
|
+
const brief = useSearch({ from: BRIEF_REPLY, shouldThrow: false });
|
|
86
|
+
const flagged = useSearch({ from: FLAGGED_REPLY, shouldThrow: false });
|
|
87
|
+
const mailbox = useSearch({ from: MAILBOX_REPLY, shouldThrow: false });
|
|
88
|
+
return (brief ?? flagged ?? mailbox)?.body;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const seededSearch =
|
|
92
|
+
(seed: ComposeSeed | undefined) =>
|
|
93
|
+
(prev: Record<string, unknown>): Record<string, unknown> =>
|
|
94
|
+
seed === undefined
|
|
95
|
+
? withoutComposeSeed(prev)
|
|
96
|
+
: { ...withoutComposeSeed(prev), body: seed.body };
|
|
97
|
+
|
|
82
98
|
/**
|
|
83
99
|
* The reply surface the address names, or none.
|
|
84
100
|
*
|
|
@@ -89,6 +105,7 @@ function useReplyParams(): ReplyParams | undefined {
|
|
|
89
105
|
*/
|
|
90
106
|
export function useReplySurface(): ReplySurface | undefined {
|
|
91
107
|
const params = useReplyParams();
|
|
108
|
+
const seedBody = useReplySeed();
|
|
92
109
|
return useMemo(() => {
|
|
93
110
|
if (!params) return undefined;
|
|
94
111
|
const mode = replyModeSchema.safeParse(params.mode);
|
|
@@ -99,8 +116,9 @@ export function useReplySurface(): ReplySurface | undefined {
|
|
|
99
116
|
threadId: params.threadId,
|
|
100
117
|
sourceMessageId: params.messageId,
|
|
101
118
|
outboxMessageId: params.outboxMessageId,
|
|
119
|
+
seed: seedBody === undefined ? undefined : { body: seedBody },
|
|
102
120
|
};
|
|
103
|
-
}, [params]);
|
|
121
|
+
}, [params, seedBody]);
|
|
104
122
|
}
|
|
105
123
|
|
|
106
124
|
/**
|
|
@@ -183,17 +201,25 @@ function inheritedDraft(
|
|
|
183
201
|
* A push, so Back leaves the reply and returns the message it was written
|
|
184
202
|
* under, and the query travels with it.
|
|
185
203
|
*/
|
|
186
|
-
export function useOpenReply(): (
|
|
204
|
+
export function useOpenReply(): (
|
|
205
|
+
target: ReplyTarget,
|
|
206
|
+
seed?: ComposeSeed,
|
|
207
|
+
) => void {
|
|
187
208
|
const navigate = useNavigate();
|
|
188
209
|
const retainPanels = useRetainOpenPanels();
|
|
189
210
|
const { list, mailboxId } = useBrowsedList();
|
|
190
211
|
const open = useReplySurface();
|
|
191
212
|
|
|
192
213
|
return useCallback(
|
|
193
|
-
(target: ReplyTarget) => {
|
|
214
|
+
(target: ReplyTarget, seed?: ComposeSeed) => {
|
|
194
215
|
navigate({
|
|
195
|
-
...replyTarget(
|
|
196
|
-
|
|
216
|
+
...replyTarget(
|
|
217
|
+
list,
|
|
218
|
+
mailboxId,
|
|
219
|
+
target,
|
|
220
|
+
seed === undefined ? inheritedDraft(open, target) : undefined,
|
|
221
|
+
),
|
|
222
|
+
search: seededSearch(seed),
|
|
197
223
|
hash: retainPanels,
|
|
198
224
|
});
|
|
199
225
|
},
|
|
@@ -254,7 +280,7 @@ export function useAdoptReplyDraft(): (outboxMessageId: string) => void {
|
|
|
254
280
|
},
|
|
255
281
|
outboxMessageId,
|
|
256
282
|
),
|
|
257
|
-
search: (
|
|
283
|
+
search: seededSearch(undefined),
|
|
258
284
|
hash: true,
|
|
259
285
|
replace: true,
|
|
260
286
|
});
|
|
@@ -278,7 +304,7 @@ export function useCloseReply(): () => void {
|
|
|
278
304
|
|
|
279
305
|
return useCallback(() => {
|
|
280
306
|
if (!params) return;
|
|
281
|
-
const search = (
|
|
307
|
+
const search = seededSearch(undefined);
|
|
282
308
|
const hash = retainPanels;
|
|
283
309
|
const message = { threadId: params.threadId, messageId: params.messageId };
|
|
284
310
|
if (list === "flagged") {
|