fixup some building of sync message issues

pull/1495/head
Audric Ackermann 4 years ago
parent e92632285b
commit ca22b4635f

@ -66,7 +66,7 @@ class ActionsPanelPrivate extends React.Component<Props> {
}
// init the messageQueue. In the constructor, we had all not send messages
// this call does nothing except calling the constructor, which will continue sending message in the pipeline
getMessageQueue();
void getMessageQueue().processAllPending();
const theme = window.Events.getThemeSetting();
window.setTheme(theme);

@ -1020,7 +1020,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
await this.commit();
}
public async sendSyncMessageOnly(dataMessage: any) {
public async sendSyncMessageOnly(dataMessage: DataMessage) {
const now = Date.now();
this.set({
sent_to: [UserUtils.getOurPubKeyStrFromCache()],

@ -211,7 +211,7 @@ async function handleExpireTimer(
await conversation.updateExpirationTimer(
expireTimer,
source,
message.get('received_at'),
message.get('sent_at') || message.get('received_at'),
{
fromGroupUpdate: message.isGroupUpdate(), // WHAT DOES GROUP UPDATE HAVE TO DO WITH THIS???
}

@ -127,15 +127,25 @@ export class ChatMessage extends DataMessage {
const timestamp = toNumber(sentTimestamp);
const body = dataMessage.body || undefined;
const wrapToUInt8Array = (buffer: any) => {
if (!buffer) {
return undefined;
}
if (buffer instanceof Uint8Array) {
// Audio messages are already uint8Array
return buffer;
}
return new Uint8Array(buffer.toArrayBuffer());
};
const attachments = (dataMessage.attachments || []).map(attachment => {
const key = wrapToUInt8Array(attachment.key);
const digest = wrapToUInt8Array(attachment.digest);
return {
...attachment,
key: attachment.key
? new Uint8Array((attachment.key as any).toArrayBuffer())
: undefined,
digest: attachment.digest
? new Uint8Array((attachment.digest as any).toArrayBuffer())
: undefined,
key,
digest,
};
}) as Array<AttachmentPointer>;
const quote = (dataMessage.quote as Quote) || undefined;

@ -169,7 +169,11 @@ export class MessageQueue {
});
}
private async processAllPending() {
/**
* This method should be called when the app is started and the user loggedin to fetch
* existing message waiting to be sent in the cache of message
*/
public async processAllPending() {
const devices = await this.pendingMessageCache.getDevices();
const promises = devices.map(async device => this.processPending(device));

Loading…
Cancel
Save