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 // 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 // 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(); const theme = window.Events.getThemeSetting();
window.setTheme(theme); window.setTheme(theme);

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

@ -211,7 +211,7 @@ async function handleExpireTimer(
await conversation.updateExpirationTimer( await conversation.updateExpirationTimer(
expireTimer, expireTimer,
source, 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??? 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 timestamp = toNumber(sentTimestamp);
const body = dataMessage.body || undefined; 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 attachments = (dataMessage.attachments || []).map(attachment => {
const key = wrapToUInt8Array(attachment.key);
const digest = wrapToUInt8Array(attachment.digest);
return { return {
...attachment, ...attachment,
key: attachment.key key,
? new Uint8Array((attachment.key as any).toArrayBuffer()) digest,
: undefined,
digest: attachment.digest
? new Uint8Array((attachment.digest as any).toArrayBuffer())
: undefined,
}; };
}) as Array<AttachmentPointer>; }) as Array<AttachmentPointer>;
const quote = (dataMessage.quote as Quote) || undefined; 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 devices = await this.pendingMessageCache.getDevices();
const promises = devices.map(async device => this.processPending(device)); const promises = devices.map(async device => this.processPending(device));

Loading…
Cancel
Save