Use MessageController whenever we create a new Message
This commit is contained in:
parent
7f958b0ff0
commit
adf21985c1
1 changed files with 21 additions and 15 deletions
|
@ -613,14 +613,15 @@
|
||||||
const id = await window.Signal.Data.saveMessage(message, {
|
const id = await window.Signal.Data.saveMessage(message, {
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
|
const model = MessageController.register(
|
||||||
this.trigger(
|
id,
|
||||||
'newmessage',
|
|
||||||
new Whisper.Message({
|
new Whisper.Message({
|
||||||
...message,
|
...message,
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.trigger('newmessage', model);
|
||||||
},
|
},
|
||||||
async addVerifiedChange(verifiedChangeId, verified, providedOptions) {
|
async addVerifiedChange(verifiedChangeId, verified, providedOptions) {
|
||||||
const options = providedOptions || {};
|
const options = providedOptions || {};
|
||||||
|
@ -657,15 +658,16 @@
|
||||||
const id = await window.Signal.Data.saveMessage(message, {
|
const id = await window.Signal.Data.saveMessage(message, {
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
|
const model = MessageController.register(
|
||||||
this.trigger(
|
id,
|
||||||
'newmessage',
|
|
||||||
new Whisper.Message({
|
new Whisper.Message({
|
||||||
...message,
|
...message,
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.trigger('newmessage', model);
|
||||||
|
|
||||||
if (this.isPrivate()) {
|
if (this.isPrivate()) {
|
||||||
ConversationController.getAllGroupsInvolvingId(this.id).then(groups => {
|
ConversationController.getAllGroupsInvolvingId(this.id).then(groups => {
|
||||||
_.forEach(groups, group => {
|
_.forEach(groups, group => {
|
||||||
|
@ -1278,7 +1280,7 @@
|
||||||
Conversation: Whisper.Conversation,
|
Conversation: Whisper.Conversation,
|
||||||
});
|
});
|
||||||
|
|
||||||
const message = this.messageCollection.add({
|
const model = new Whisper.Message({
|
||||||
// Even though this isn't reflected to the user, we want to place the last seen
|
// Even though this isn't reflected to the user, we want to place the last seen
|
||||||
// indicator above it. We set it to 'unread' to trigger that placement.
|
// indicator above it. We set it to 'unread' to trigger that placement.
|
||||||
unread: 1,
|
unread: 1,
|
||||||
|
@ -1294,17 +1296,21 @@
|
||||||
fromGroupUpdate: options.fromGroupUpdate,
|
fromGroupUpdate: options.fromGroupUpdate,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (this.isPrivate()) {
|
|
||||||
message.set({ destination: this.id });
|
|
||||||
}
|
|
||||||
if (message.isOutgoing()) {
|
|
||||||
message.set({ recipients: this.getRecipients() });
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = await window.Signal.Data.saveMessage(message.attributes, {
|
if (this.isPrivate()) {
|
||||||
|
model.set({ destination: this.id });
|
||||||
|
}
|
||||||
|
if (model.isOutgoing()) {
|
||||||
|
model.set({ recipients: this.getRecipients() });
|
||||||
|
}
|
||||||
|
const id = await window.Signal.Data.saveMessage(model.attributes, {
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
message.set({ id });
|
|
||||||
|
model.set({ id });
|
||||||
|
|
||||||
|
const message = MessageController.register(id, model);
|
||||||
|
this.messageCollection.add(message);
|
||||||
|
|
||||||
// if change was made remotely, don't send it to the number/group
|
// if change was made remotely, don't send it to the number/group
|
||||||
if (receivedAt) {
|
if (receivedAt) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue