@zoralabs/cli 1.2.0 → 1.4.0
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.
|
@@ -96,6 +96,7 @@ var createMessagingClient = async (spec, options = {}) => {
|
|
|
96
96
|
sentAtMs: Number(message.sentAtNs / 1000000n)
|
|
97
97
|
});
|
|
98
98
|
const findDm = (peerAddress) => client.conversations.fetchDmByIdentifier(toIdentifier(peerAddress));
|
|
99
|
+
let streamAbort;
|
|
99
100
|
return {
|
|
100
101
|
address,
|
|
101
102
|
async sync(consent) {
|
|
@@ -156,7 +157,34 @@ var createMessagingClient = async (spec, options = {}) => {
|
|
|
156
157
|
}
|
|
157
158
|
await dm.updateConsentState(CONSENT_TO_SDK[consent]);
|
|
158
159
|
},
|
|
160
|
+
streamAllMessages() {
|
|
161
|
+
const ctrl = new AbortController();
|
|
162
|
+
streamAbort = ctrl;
|
|
163
|
+
const outerClient = client;
|
|
164
|
+
async function* generate() {
|
|
165
|
+
await outerClient.conversations.sync();
|
|
166
|
+
const stream = await outerClient.conversations.streamAllMessages();
|
|
167
|
+
for await (const message of stream) {
|
|
168
|
+
if (ctrl.signal.aborted) break;
|
|
169
|
+
let convo = outerClient.conversations.listDms().find((dm) => dm.id === message.conversationId);
|
|
170
|
+
if (!convo) {
|
|
171
|
+
await outerClient.conversations.sync();
|
|
172
|
+
convo = outerClient.conversations.listDms().find((dm) => dm.id === message.conversationId);
|
|
173
|
+
if (!convo) continue;
|
|
174
|
+
}
|
|
175
|
+
const addrByInbox = await addressMapForDm(convo);
|
|
176
|
+
const dmMessage = toMessage(message, addrByInbox);
|
|
177
|
+
const peerAddr = addrByInbox.get(convo.peerInboxId) ?? null;
|
|
178
|
+
yield { ...dmMessage, peerAddress: peerAddr };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return generate();
|
|
182
|
+
},
|
|
159
183
|
async close() {
|
|
184
|
+
if (streamAbort) {
|
|
185
|
+
streamAbort.abort();
|
|
186
|
+
streamAbort = void 0;
|
|
187
|
+
}
|
|
160
188
|
}
|
|
161
189
|
};
|
|
162
190
|
};
|