@pmate/chat-sdk 0.12.0-next.29 → 0.12.0-next.30
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.
|
@@ -26,8 +26,14 @@ export function projectMessageTimeline(input) {
|
|
|
26
26
|
records.set(message.id, { message, status: pending.status });
|
|
27
27
|
}
|
|
28
28
|
for (const message of input.messages)
|
|
29
|
-
if (scoped(message))
|
|
30
|
-
|
|
29
|
+
if (scoped(message)) {
|
|
30
|
+
const legacy = message.legacyDisplay;
|
|
31
|
+
if (legacy && records.has(message.id))
|
|
32
|
+
continue;
|
|
33
|
+
const legacyStatus = legacy?.status;
|
|
34
|
+
const status = legacyStatus === "failed" || legacyStatus === "sending" || legacyStatus === "read" ? legacyStatus : "sent";
|
|
35
|
+
records.set(message.id, { message, status });
|
|
36
|
+
}
|
|
31
37
|
const recalled = new Map(), reactions = new Map();
|
|
32
38
|
const addReaction = (event) => {
|
|
33
39
|
const key = JSON.stringify([event.messageId, event.from, event.emojiId]), old = reactions.get(key);
|
|
@@ -86,7 +92,7 @@ export function projectMessageTimeline(input) {
|
|
|
86
92
|
continue;
|
|
87
93
|
const mine = envelope.from === input.profileId, reading = input.reading[message.id];
|
|
88
94
|
const withdrawn = Boolean(message.recalled || envelope.legacyDisplay?.recalled || envelope.from && recalled.get(message.id)?.has(envelope.from));
|
|
89
|
-
const item = { id: message.id, threadId: message.threadId, timestamp: message.timestamp, from: envelope.from, mine, status: !mine && reading
|
|
95
|
+
const item = { id: message.id, threadId: message.threadId, timestamp: message.timestamp, from: envelope.from, mine, status: !mine && reading ? (reading.read ? "read" : status === "read" ? "sent" : status) : status, recalled: withdrawn,
|
|
90
96
|
message: withdrawn ? undefined : message, reading, reactions: withdrawn ? [] : [...(grouped.get(message.id) ?? [])].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([emojiId, users]) => { const userIds = [...users].sort(); return { emojiId, userIds, mine: userIds.includes(input.profileId) }; }) };
|
|
91
97
|
const old = previous.get(item.id);
|
|
92
98
|
const sameReading = old?.reading === item.reading || old?.reading?.seq === item.reading?.seq && old?.reading?.read === item.reading?.read && old?.reading?.readPolicy === item.reading?.readPolicy;
|
package/package.json
CHANGED