@remit/web-client 0.0.20 → 0.0.21
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.
|
|
3
|
+
"version": "0.0.21",
|
|
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": {
|
|
@@ -161,9 +161,10 @@ export const ConversationView = ({
|
|
|
161
161
|
error,
|
|
162
162
|
refetch,
|
|
163
163
|
} = useQuery({
|
|
164
|
+
// The API reads a conversation oldest first (#81) and the pane renders it
|
|
165
|
+
// in that order, so no `order` is asked for and none is re-sorted here.
|
|
164
166
|
...threadDetailOperationsListThreadMessagesOptions({
|
|
165
167
|
path: { threadId },
|
|
166
|
-
query: { order: "desc" },
|
|
167
168
|
}),
|
|
168
169
|
});
|
|
169
170
|
|
|
@@ -171,21 +172,24 @@ export const ConversationView = ({
|
|
|
171
172
|
() => messagesResponse?.items ?? [],
|
|
172
173
|
[messagesResponse?.items],
|
|
173
174
|
);
|
|
175
|
+
const latestMessage = messages[messages.length - 1];
|
|
174
176
|
const messageRefs = useRef<Map<string, HTMLDivElement>>(new Map());
|
|
175
177
|
|
|
176
178
|
// Track which messages are expanded
|
|
177
|
-
// By default, the
|
|
179
|
+
// By default, the latest message is expanded
|
|
178
180
|
const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());
|
|
179
181
|
const [currentThreadId, setCurrentThreadId] = useState<string | null>(null);
|
|
180
182
|
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
181
183
|
|
|
182
|
-
// Reset and expand
|
|
184
|
+
// Reset and expand the latest message when thread changes or messages load.
|
|
183
185
|
// Also expand the selected message (the row the user clicked in the list)
|
|
184
186
|
// so that an older unread message is visible and gets marked as read.
|
|
185
187
|
useEffect(() => {
|
|
186
188
|
if (messages.length > 0 && threadId !== currentThreadId) {
|
|
187
189
|
setCurrentThreadId(threadId);
|
|
188
|
-
const initialExpanded = new Set([
|
|
190
|
+
const initialExpanded = new Set([
|
|
191
|
+
messages[messages.length - 1].threadMessageId,
|
|
192
|
+
]);
|
|
189
193
|
if (selectedMessageId) {
|
|
190
194
|
const selected = messages.find(
|
|
191
195
|
(m) => m.messageId === selectedMessageId,
|
|
@@ -193,7 +197,7 @@ export const ConversationView = ({
|
|
|
193
197
|
if (selected) initialExpanded.add(selected.threadMessageId);
|
|
194
198
|
}
|
|
195
199
|
setExpandedIds(initialExpanded);
|
|
196
|
-
setFocusedIndex(
|
|
200
|
+
setFocusedIndex(messages.length - 1);
|
|
197
201
|
}
|
|
198
202
|
}, [threadId, messages, currentThreadId, selectedMessageId]);
|
|
199
203
|
|
|
@@ -283,12 +287,13 @@ export const ConversationView = ({
|
|
|
283
287
|
}
|
|
284
288
|
}, [composeRequest, onComposeClose]);
|
|
285
289
|
|
|
286
|
-
|
|
287
|
-
|
|
290
|
+
// Reply and forward act on the latest turn of the conversation, which is the
|
|
291
|
+
// last message now that the thread reads oldest first.
|
|
292
|
+
const { data: latestMessageData } = useQuery({
|
|
288
293
|
...messageOperationsDescribeMessageOptions({
|
|
289
|
-
path: { messageId:
|
|
294
|
+
path: { messageId: latestMessage?.messageId ?? "" },
|
|
290
295
|
}),
|
|
291
|
-
enabled: !!
|
|
296
|
+
enabled: !!latestMessage && composeMode !== null,
|
|
292
297
|
});
|
|
293
298
|
|
|
294
299
|
const handleReply = useCallback(() => {
|
|
@@ -432,7 +437,7 @@ export const ConversationView = ({
|
|
|
432
437
|
<InlineCompose
|
|
433
438
|
mode={composeMode}
|
|
434
439
|
account={activeAccount}
|
|
435
|
-
sourceMessage={
|
|
440
|
+
sourceMessage={latestMessageData}
|
|
436
441
|
onClose={handleCloseCompose}
|
|
437
442
|
/>
|
|
438
443
|
)}
|
|
@@ -454,7 +459,7 @@ export const ConversationView = ({
|
|
|
454
459
|
<InlineCompose
|
|
455
460
|
mode={composeMode}
|
|
456
461
|
account={activeAccount}
|
|
457
|
-
sourceMessage={
|
|
462
|
+
sourceMessage={latestMessageData}
|
|
458
463
|
onClose={handleCloseCompose}
|
|
459
464
|
/>
|
|
460
465
|
)}
|