mnfst 0.5.196 → 0.5.197
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/lib/manifest.chat.js +15 -2
- package/lib/manifest.integrity.json +1 -1
- package/package.json +1 -1
package/lib/manifest.chat.js
CHANGED
|
@@ -106,11 +106,24 @@
|
|
|
106
106
|
for (const k of Object.keys(incoming)) if (k !== 'body' && k !== '_seq') target[k] = incoming[k];
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
// own echo beating the ack: claim the pending row by meta.clientId
|
|
110
|
+
function claimPending(incoming) {
|
|
111
|
+
const cid = incoming.meta && incoming.meta.clientId;
|
|
112
|
+
if (cid == null || !state.me || !incoming.author || incoming.author.id !== state.me.id) return null;
|
|
113
|
+
return _msgs.find(m => m._optimistic && m._clientId === cid) || null;
|
|
114
|
+
}
|
|
115
|
+
|
|
109
116
|
function upsert(raw) {
|
|
110
117
|
const incoming = normalize(raw, ++seq);
|
|
111
118
|
const prev = incoming.id != null ? _byId.get(incoming.id) : null;
|
|
119
|
+
const pending = prev ? null : claimPending(incoming);
|
|
112
120
|
if (prev) {
|
|
113
121
|
merge(prev, incoming);
|
|
122
|
+
} else if (pending) {
|
|
123
|
+
_byId.delete(pending.id);
|
|
124
|
+
merge(pending, incoming);
|
|
125
|
+
pending._optimistic = false;
|
|
126
|
+
if (pending.id != null) _byId.set(pending.id, pending);
|
|
114
127
|
} else {
|
|
115
128
|
_msgs.push(incoming);
|
|
116
129
|
if (incoming.id != null) _byId.set(incoming.id, incoming);
|
|
@@ -176,11 +189,11 @@
|
|
|
176
189
|
async function send(draft) {
|
|
177
190
|
const tmp = 'tmp_' + (++seq);
|
|
178
191
|
const body = draft && draft.body ? draft.body : { text: draft && draft.text != null ? draft.text : '' };
|
|
179
|
-
const local = normalize({ id: tmp, conversationId, author: state.me, body, replyTo: draft && draft.replyTo, status: 'pending', ts: null, _optimistic: true }, ++seq);
|
|
192
|
+
const local = normalize({ id: tmp, conversationId, author: state.me, body, replyTo: draft && draft.replyTo, status: 'pending', ts: null, _optimistic: true, _clientId: tmp }, ++seq);
|
|
180
193
|
_msgs.push(local); _byId.set(tmp, local); commit();
|
|
181
194
|
if (!adapter.send) { local.status = 'failed'; local.statusReason = 'unsupported'; commit(); return; }
|
|
182
195
|
try {
|
|
183
|
-
const ack = await adapter.send(conversationId, Object.assign({}, draft, { body }));
|
|
196
|
+
const ack = await adapter.send(conversationId, Object.assign({}, draft, { body, clientId: tmp }));
|
|
184
197
|
_byId.delete(tmp);
|
|
185
198
|
// A bus that echoes our own send can beat the ack; that echo lands
|
|
186
199
|
// while this row is still tmp-keyed, so it appended as its own entry.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"manifest.appwrite.data.js": "sha384-cfiPqikpRrY3hJkSUIKese6/jJAW67EMm/RX4w3332onpNUyZn6zkWcxJm/wquUf",
|
|
4
4
|
"manifest.appwrite.presences.js": "sha384-JyVDWFT69b7Svq8J8p9tNWe2v9PZNQBY5UyhtOl1vnuHFAX0CRQ3MA9SiKq5wzNh",
|
|
5
5
|
"manifest.charts.js": "sha384-qQrjhWkIDi4oU5uQrpy8DdlMjY+gfiivBuX6mssNiFdkawgkVBvKneGgp+nd3PYJ",
|
|
6
|
-
"manifest.chat.js": "sha384-
|
|
6
|
+
"manifest.chat.js": "sha384-UN5BmhqyafJ8OfLFaOLszrvUW5r001dRheQWqsEBCCLnfBcW1bjXaGOdZvURtrnL",
|
|
7
7
|
"manifest.code.js": "sha384-aoQ4E26vrhNe/+tL7K0h90c8/0ies7e8oIR6Ay92he2X3dnWZ+OPcn2Dna8fmc+c",
|
|
8
8
|
"manifest.color.js": "sha384-6Rv3LxyTcZNjrhtayQfqRdCx0uSZ4BiEbgEI98I62eTvp8Aw7LBIoNJ0Je1oktwL",
|
|
9
9
|
"manifest.colorpicker.js": "sha384-1+ZV5Hhjf7WnGP7b71Cqa5h3BKW8UgGT5V14i8Q+aF5zH8Xxwowt/ibSUVsiIHSm",
|