@@ -10,10 +10,11 @@ import toastr from 'toastr';
1010
1111import { OTR } from './rocketchat.otr' ;
1212import { Notifications } from '../../notifications' ;
13- import { modal } from '../../ui-utils' ;
1413import { getUidDirectMessage } from '../../ui-utils/client/lib/getUidDirectMessage' ;
1514import { Presence } from '../../../client/lib/presence' ;
1615import { goToRoomById } from '../../../client/lib/goToRoomById' ;
16+ import { imperativeModal } from '../../../client/lib/imperativeModal' ;
17+ import GenericModal from '../../../client/components/GenericModal' ;
1718
1819OTR . Room = class {
1920 constructor ( userId , roomId ) {
@@ -208,31 +209,32 @@ OTR.Room = class {
208209 this . reset ( ) ;
209210 }
210211
211- modal . open ( {
212- title : TAPi18n . __ ( 'OTR' ) ,
213- text : TAPi18n . __ ( 'Username_wants_to_start_otr_Do_you_want_to_accept' , { username } ) ,
214- html : true ,
215- showCancelButton : true ,
216- allowOutsideClick : false ,
217- confirmButtonText : TAPi18n . __ ( 'Yes' ) ,
218- cancelButtonText : TAPi18n . __ ( 'No' ) ,
219- } , ( isConfirm ) => {
220- if ( isConfirm ) {
221- establishConnection ( ) ;
222- } else {
223- Meteor . clearTimeout ( timeout ) ;
224- this . deny ( ) ;
225- }
212+ imperativeModal . open ( { component : GenericModal ,
213+ props : {
214+ variant : 'warning' ,
215+ title : TAPi18n . __ ( 'OTR' ) ,
216+ children : TAPi18n . __ ( 'Username_wants_to_start_otr_Do_you_want_to_accept' , { username } ) ,
217+ confirmText : TAPi18n . __ ( 'Yes' ) ,
218+ cancelText : TAPi18n . __ ( 'No' ) ,
219+ onClose : ( ) => imperativeModal . close ,
220+ onCancel : ( ) => {
221+ Meteor . clearTimeout ( timeout ) ;
222+ this . deny ( ) ;
223+ imperativeModal . close ( ) ;
224+ } ,
225+ onConfirm : ( ) => {
226+ establishConnection ( ) ;
227+ imperativeModal . close ( ) ;
228+ } ,
229+ } ,
226230 } ) ;
227231 }
228232
229233 timeout = Meteor . setTimeout ( ( ) => {
230234 this . establishing . set ( false ) ;
231- modal . close ( ) ;
235+ imperativeModal . close ( ) ;
232236 } , 10000 ) ;
233237 } ) ( ) ;
234-
235-
236238 break ;
237239
238240 case 'acknowledge' :
@@ -242,28 +244,41 @@ OTR.Room = class {
242244 break ;
243245
244246 case 'deny' :
245- if ( this . establishing . get ( ) ) {
246- this . reset ( ) ;
247- const user = Meteor . users . findOne ( this . peerId ) ;
248- modal . open ( {
249- title : TAPi18n . __ ( 'OTR' ) ,
250- text : TAPi18n . __ ( 'Username_denied_the_OTR_session' , { username : user . username } ) ,
251- html : true ,
252- } ) ;
253- }
247+ ( async ( ) => {
248+ const { username } = await Presence . get ( this . peerId ) ;
249+ if ( this . establishing . get ( ) ) {
250+ this . reset ( ) ;
251+ imperativeModal . open ( { component : GenericModal ,
252+ props : {
253+ variant : 'warning' ,
254+ title : TAPi18n . __ ( 'OTR' ) ,
255+ children : TAPi18n . __ ( 'Username_denied_the_OTR_session' , { username } ) ,
256+ onClose : imperativeModal . close ,
257+ onConfirm : imperativeModal . close ,
258+ } ,
259+ } ) ;
260+ }
261+ } ) ( ) ;
254262 break ;
255263
256264 case 'end' :
257- if ( this . established . get ( ) ) {
258- this . reset ( ) ;
259- const user = Meteor . users . findOne ( this . peerId ) ;
260- modal . open ( {
261- title : TAPi18n . __ ( 'OTR' ) ,
262- text : TAPi18n . __ ( 'Username_ended_the_OTR_session' , { username : user . username } ) ,
263- html : true ,
264- confirmButtonText : TAPi18n . __ ( 'Ok' ) ,
265- } ) ;
266- }
265+ ( async ( ) => {
266+ const { username } = await Presence . get ( this . peerId ) ;
267+
268+ if ( this . established . get ( ) ) {
269+ this . reset ( ) ;
270+ imperativeModal . open ( { component : GenericModal ,
271+ props : {
272+ variant : 'warning' ,
273+ title : TAPi18n . __ ( 'OTR' ) ,
274+ children : TAPi18n . __ ( 'Username_ended_the_OTR_session' , { username } ) ,
275+ confirmText : TAPi18n . __ ( 'Ok' ) ,
276+ onClose : imperativeModal . close ,
277+ onConfirm : imperativeModal . close ,
278+ } ,
279+ } ) ;
280+ }
281+ } ) ( ) ;
267282 break ;
268283 }
269284 }
0 commit comments