remove completely messageCollectiom from conversationModel

pull/1530/head
Audric Ackermann 4 years ago
parent 35e57f2509
commit 65ba2add46
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1,5 +1,3 @@
this.messageCollection
indexeddb

@ -1,4 +1,4 @@
/* global Signal, setTimeout, clearTimeout, getMessageController, NewReceiver, models */
/* global Signal, setTimeout, clearTimeout, getMessageController, NewReceiver */
const { isNumber, omit } = require('lodash');
const getGuid = require('uuid/v4');

@ -575,9 +575,9 @@ describe('Backup', () => {
);
console.log('Backup test: Check messages');
const messageCollection = await window.Signal.Data.getAllMessages();
assert.strictEqual(messageCollection.length, MESSAGE_COUNT);
const messageFromDB = removeId(messageCollection.at(0).attributes);
const allMessages = await window.Signal.Data.getAllMessages();
assert.strictEqual(allMessages.length, MESSAGE_COUNT);
const messageFromDB = removeId(allMessages.at(0).attributes);
const expectedMessage = messageFromDB;
console.log({ messageFromDB, expectedMessage });
assert.deepEqual(messageFromDB, expectedMessage);

@ -54,29 +54,29 @@ Whisper.Fixtures = () => {
]);
const Vera = conversationCollection.get(VERA_ID);
Vera.messageCollection.add([
Vera.addSingleMessage(
{
conversationId: VERA_ID,
type: 'incoming',
sent_at: now - 10000000,
received_at: now - 10000000,
body: 'My piece for Iskra is ready!',
},
]);
}
);
const Nestor = conversationCollection.get(NESTOR_ID);
Nestor.messageCollection.add([
Nestor.addSingleMessage(
{
conversationId: NESTOR_ID,
type: 'incoming',
sent_at: now - 1000000000,
received_at: now - 1000000000,
body: 'Need a ride?',
},
]);
}
);
const Fred = conversationCollection.get(FRED_ID);
Fred.messageCollection.add([
Fred.addSingleMessage(
{
conversationId: FRED_ID,
type: 'incoming',
@ -84,11 +84,11 @@ Whisper.Fixtures = () => {
received_at: now - 500000000,
body:
'It is my ambition to say in ten sentences what everyone else says in a whole book — what everyone else does not say in a whole book.',
},
]);
}
);
const Michel = conversationCollection.get(MICHEL_ID);
Michel.messageCollection.add([
Michel.addSingleMessage(
{
conversationId: MICHEL_ID,
type: 'outgoing',
@ -100,15 +100,16 @@ Whisper.Fixtures = () => {
data: dataURItoBlob(getImage1()),
},
],
},
{
conversationId: MICHEL_ID,
type: 'incoming',
body: 'The soul is the prison of the body.',
sent_at: now - 1000000,
received_at: now - 1000000,
source: MICHEL_ID,
},
});
Michel.addSingleMessage({
conversationId: MICHEL_ID,
type: 'incoming',
body: 'The soul is the prison of the body.',
sent_at: now - 1000000,
received_at: now - 1000000,
source: MICHEL_ID,
});
Michel.addSingleMessage(
{
conversationId: MICHEL_ID,
type: 'incoming',
@ -117,55 +118,57 @@ Whisper.Fixtures = () => {
'In their opinion I am a dangerous man, since I am a crypto-Marxist.',
received_at: now - 2000000,
source: MICHEL_ID,
},
]);
});
const Masha = conversationCollection.get(MASHA_ID);
Masha.messageCollection.add(
[
{
date: now - 60000,
type: 'incoming',
source: MASHA_ID,
attachments: [
{
contentType: 'image/jpeg',
data: dataURItoBlob(getImage2()),
},
],
},
{
date: now - 5000,
type: 'outgoing',
body: 'I just installed Signal Desktop!',
},
{
date: now - 4000,
type: 'outgoing',
body:
'Now I can use Signal on my computer, even when my phone is off. 😄 ',
},
{
date: now,
type: 'incoming',
source: MASHA_ID,
body: "I can't wait to try it!",
unread: 1,
},
].map((m) => {
return {
conversationId: MASHA_ID,
type: m.type,
body: m.body,
sent_at: m.date,
received_at: m.date,
timestamp: m.date,
attachments: m.attachments,
unread: m.unread,
source: m.source,
};
})
);
Masha.addSingleMessage(
{
date: now - 60000,
type: 'incoming',
source: MASHA_ID,
attachments: [
{
contentType: 'image/jpeg',
data: dataURItoBlob(getImage2()),
},
],
conversationId: MASHA_ID,
sent_at: now - 60000,
received_at: now - 60000,
timestamp: now - 60000,
});
Masha.addSingleMessage(
{
date: now - 5000,
type: 'outgoing',
body: 'I just installed Signal Desktop!',
conversationId: MASHA_ID,
sent_at: now - 5000,
received_at: now - 5000,
timestamp: now - 5000,
});
Masha.addSingleMessage({
date: now - 4000,
type: 'outgoing',
body:
'Now I can use Signal on my computer, even when my phone is off. 😄 ',
conversationId: MASHA_ID,
sent_at: now - 4000,
received_at: now - 4000,
timestamp: now - 4000,
});
Masha.addSingleMessage({
date: now,
type: 'incoming',
source: MASHA_ID,
body: "I can't wait to try it!",
unread: 1,
conversationId: MASHA_ID,
sent_at: now,
received_at: now,
timestamp: now,
});
const group = conversationCollection.add({
name: '📖 Book Club',
@ -176,51 +179,60 @@ Whisper.Fixtures = () => {
lastMessage: 'See you all there!',
members: [MICHEL_ID, FRED_ID, NESTOR_ID],
});
group.messageCollection.add(
[
group.addSingleMessage(
{
date: now - 60 * 1000 * 30,
sent_at: now - 60 * 1000 * 30,
received_at: now - 60 * 1000 * 30,
timestamp: now - 60 * 1000 * 30,
type: 'incoming',
body:
'If you knew when you began a book what you would say at the end, do you think that you would have the courage to write it?',
source: MICHEL_ID,
},
{
date: now - 60 * 1000 * 20,
type: 'incoming',
body:
'A book which has a strange knack of seeking out its fellow-revellers and enticing them on to new secret paths and dancing-places.',
source: FRED_ID,
},
{
date: now - 60 * 1000 * 4,
type: 'incoming',
body: "Let's meet in the library.",
source: NESTOR_ID,
},
{
date: now - 60 * 1000,
type: 'incoming',
body: "I'll be a little late.",
source: NESTOR_ID,
},
{
date: now,
type: 'outgoing',
body: 'See you all there!',
recipients: [MICHEL_ID, FRED_ID, NESTOR_ID],
delivered_to: [MICHEL_ID, FRED_ID],
sent_to: [NESTOR_ID],
},
].map((m) => {
return Object.assign({}, m, {
conversationId: group.id,
sent_at: m.date,
received_at: m.date,
timestamp: m.date,
});
})
);
group.addSingleMessage(
{
sent_at: now - 60 * 1000 * 20,
received_at: now - 60 * 1000 * 20,
timestamp: now - 60 * 1000 * 20,
type: 'incoming',
body:
'A book which has a strange knack of seeking out its fellow-revellers and enticing them on to new secret paths and dancing-places.',
source: FRED_ID,
conversationId: group.id,
});
group.addSingleMessage(
{
sent_at: now - 60 * 1000 * 4,
received_at: now - 60 * 1000 * 4,
timestamp: now - 60 * 1000 * 4,
type: 'incoming',
body: "Let's meet in the library.",
source: NESTOR_ID,
conversationId: group.id,
});
group.addSingleMessage(
{
sent_at: now - 60 * 1000,
received_at: now - 60 * 1000,
timestamp: now - 60 * 1000,
type: 'incoming',
body: "I'll be a little late.",
source: NESTOR_ID,
conversationId: group.id,
});
group.addSingleMessage(
{
sent_at: now,
received_at: now,
timestamp: now,
type: 'outgoing',
body: 'See you all there!',
recipients: [MICHEL_ID, FRED_ID, NESTOR_ID],
delivered_to: [MICHEL_ID, FRED_ID],
sent_to: [NESTOR_ID],
conversationId: group.id,
});
function dataURItoBlob(dataURI) {
const binary = atob(dataURI.split(',')[1]);

Loading…
Cancel
Save