mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-07-13 16:43:53 +01:00
Rename createTemporary to dangerouslyCreateAndAdd
Class: `ConversationController`. This function should not be used in application code as it creates potentially invalid `Conversation` instances in our global conversation collection. We keep making it available for testing purposes.
This commit is contained in:
@@ -95,7 +95,7 @@
|
||||
getUnsafe: function(id) {
|
||||
return conversations.get(id);
|
||||
},
|
||||
createTemporary: function(attributes) {
|
||||
dangerouslyCreateAndAdd: function(attributes) {
|
||||
return conversations.add(attributes);
|
||||
},
|
||||
getOrCreate: function(id, type) {
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
// Creates a view to display a new contact
|
||||
this.new_contact_view = new Whisper.NewContactView({
|
||||
el: this.$new_contact,
|
||||
model: ConversationController.createTemporary({
|
||||
model: ConversationController.dangerouslyCreateAndAdd({
|
||||
type: 'private',
|
||||
}),
|
||||
}).render();
|
||||
|
||||
@@ -16,9 +16,12 @@ describe('KeyChangeListener', function() {
|
||||
});
|
||||
|
||||
describe('When we have a conversation with this contact', function() {
|
||||
var convo = new Whisper.Conversation({ id: phoneNumberWithKeyChange, type: 'private'});
|
||||
let convo;
|
||||
before(function() {
|
||||
ConversationController.createTemporary(convo);
|
||||
convo = ConversationController.dangerouslyCreateAndAdd({
|
||||
id: phoneNumberWithKeyChange,
|
||||
type: 'private',
|
||||
});
|
||||
return convo.save();
|
||||
});
|
||||
|
||||
@@ -41,9 +44,13 @@ describe('KeyChangeListener', function() {
|
||||
|
||||
|
||||
describe('When we have a group with this contact', function() {
|
||||
var convo = new Whisper.Conversation({ id: 'groupId', type: 'group', members: [phoneNumberWithKeyChange] });
|
||||
let convo;
|
||||
before(function() {
|
||||
ConversationController.createTemporary(convo);
|
||||
convo = ConversationController.dangerouslyCreateAndAdd({
|
||||
id: 'groupId',
|
||||
type: 'group',
|
||||
members: [phoneNumberWithKeyChange],
|
||||
});
|
||||
return convo.save();
|
||||
});
|
||||
after(function() {
|
||||
|
||||
@@ -2,7 +2,7 @@ describe('MessageView', function() {
|
||||
var convo, message;
|
||||
|
||||
before(function() {
|
||||
convo = ConversationController.createTemporary({id: 'foo'});
|
||||
convo = ConversationController.dangerouslyCreateAndAdd({id: 'foo'});
|
||||
message = convo.messageCollection.add({
|
||||
conversationId: convo.id,
|
||||
body: 'hello world',
|
||||
|
||||
Reference in New Issue
Block a user