Skip to content

Commit

Permalink
Merge pull request #22546 from RocketChat/improve/accept-otr-modal
Browse files Browse the repository at this point in the history
[IMPROVE] Rewrite accept OTR modal
  • Loading branch information
gabriellsh authored Jul 5, 2021
2 parents 1c133eb + bdfb5ea commit ff640c1
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions app/otr/client/rocketchat.otr.room.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { modal } from '../../ui-utils';
import { getUidDirectMessage } from '../../ui-utils/client/lib/getUidDirectMessage';
import { Presence } from '../../../client/lib/presence';
import { goToRoomById } from '../../../client/lib/goToRoomById';
import { imperativeModal } from '../../../client/lib/imperativeModal';
import GenericModal from '../../../client/components/GenericModal';

OTR.Room = class {
constructor(userId, roomId) {
Expand Down Expand Up @@ -208,27 +210,30 @@ OTR.Room = class {
this.reset();
}

modal.open({
title: TAPi18n.__('OTR'),
text: TAPi18n.__('Username_wants_to_start_otr_Do_you_want_to_accept', { username }),
html: true,
showCancelButton: true,
allowOutsideClick: false,
confirmButtonText: TAPi18n.__('Yes'),
cancelButtonText: TAPi18n.__('No'),
}, (isConfirm) => {
if (isConfirm) {
establishConnection();
} else {
Meteor.clearTimeout(timeout);
this.deny();
}
imperativeModal.open({ component: GenericModal,
props: {
variant: 'warning',
title: TAPi18n.__('OTR'),
children: TAPi18n.__('Username_wants_to_start_otr_Do_you_want_to_accept', { username }),
confirmText: TAPi18n.__('Yes'),
cancelText: TAPi18n.__('No'),
onClose: () => imperativeModal.close,
onCancel: () => {
Meteor.clearTimeout(timeout);
this.deny();
imperativeModal.close();
},
onConfirm: () => {
establishConnection();
imperativeModal.close();
},
},
});
}

timeout = Meteor.setTimeout(() => {
this.establishing.set(false);
modal.close();
imperativeModal.close();
}, 10000);
})();

Expand Down

0 comments on commit ff640c1

Please sign in to comment.