Strengthen precondition of ConversationController.getOrCreate

This commit is contained in:
Daniel Gasienica 2018-03-27 19:00:25 -04:00
parent 83c979fb84
commit 08f6886f3e

View file

@ -99,6 +99,14 @@
return conversations.add(attributes);
},
getOrCreate: function(id, type) {
if (typeof id !== 'string') {
throw new TypeError('"id" must be a string');
}
if (type !== 'private' && type !== 'group') {
throw new TypeError('"type" must be "private" or "group"; got: ' + type);
}
if (!this._initialFetchComplete) {
throw new Error('ConversationController.get() needs complete initial fetch');
}