@ -89,32 +89,27 @@
this . new _contact _view . undelegateEvents ( ) ;
this . new _contact _view . undelegateEvents ( ) ;
this . new _contact _view . $el . hide ( ) ;
this . new _contact _view . $el . hide ( ) ;
}
}
// Creates a view to display a new contact
const model = new Whisper . Conversation ( { type : 'private' } ) ;
this . new _contact _view = new Whisper . NewContactView ( {
this . new _contact _view = new Whisper . NewContactView ( {
el : this . $new _contact ,
el : this . $new _contact ,
model : ConversationController . dangerouslyCreateAndAdd ( {
model ,
type : 'private' ,
} ) ,
} ) . render ( ) ;
} ) . render ( ) ;
} ,
} ,
createConversation ( ) {
async createConversation ( ) {
if ( this . new _contact _view . model . isValid ( ) ) {
const isValidNumber = this . new _contact _view . model . isValid ( ) ;
// NOTE: Temporarily allow `then` until we convert the entire file
if ( ! isValidNumber ) {
// to `async` / `await`:
// eslint-disable-next-line more/no-then
ConversationController . getOrCreateAndWait (
this . new _contact _view . model . id ,
'private'
) . then ( ( conversation ) => {
this . trigger ( 'open' , conversation ) ;
this . initNewContact ( ) ;
this . resetTypeahead ( ) ;
} ) ;
} else {
this . new _contact _view . $ ( '.number' ) . text ( i18n ( 'invalidNumberError' ) ) ;
this . new _contact _view . $ ( '.number' ) . text ( i18n ( 'invalidNumberError' ) ) ;
this . $input . focus ( ) ;
this . $input . focus ( ) ;
return ;
}
}
const newConversationId = this . new _contact _view . model . id ;
const conversation =
await ConversationController . getOrCreateAndWait ( newConversationId , 'private' ) ;
this . trigger ( 'open' , conversation ) ;
this . initNewContact ( ) ;
this . resetTypeahead ( ) ;
} ,
} ,
reset ( ) {
reset ( ) {