Commit fd3bb570 authored by JC Brand's avatar JC Brand

Add an `omemo_active` flag on the chatbox

updates #497
parent 96456415
......@@ -146,11 +146,13 @@
}).then(function () {
const view = _converse.chatboxviews.get(contact_jid);
const toolbar = view.el.querySelector('.chat-toolbar');
expect(view.model.get('omemo_active')).toBe(undefined);
expect(_.isNull(toolbar.querySelector('.toggle-omemo'))).toBe(false);
spyOn(view, 'toggleOMEMO').and.callThrough();
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
toolbar.querySelector('.toggle-omemo').click();
expect(view.toggleOMEMO).toHaveBeenCalled();
expect(view.model.get('omemo_active')).toBe(true);
done();
}).catch(_.partial(console.error, _));
}));
......
......@@ -328,18 +328,16 @@
},
getOutgoingMessageAttributes (text, spoiler_hint) {
const fullname = _converse.xmppstatus.get('fullname'),
is_spoiler = this.get('composing_spoiler');
return {
'fullname': fullname,
const is_spoiler = this.get('composing_spoiler');
return _.extend(this.toJSON(), {
'fullname': _converse.xmppstatus.get('fullname'),
'from': _converse.bare_jid,
'sender': 'me',
'time': moment().format(),
'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined,
'is_spoiler': is_spoiler,
'spoiler_hint': is_spoiler ? spoiler_hint : undefined
};
});
},
sendMessage (attrs) {
......
......@@ -65,8 +65,8 @@
},
toggleOMEMO (ev) {
// TODO:
ev.preventDefault();
this.model.save({'omemo_active': !this.model.get('omemo_active')});
}
}
},
......
......@@ -237,7 +237,7 @@
this.trigger('showReceivedOTRMessage', msg);
});
this.otr.on('io', (msg) => {
this.sendMessage(new _converse.Message({'message':msg}));
this.sendMessage({'message':msg});
});
this.otr.on('error', (msg) => {
this.trigger('showOTRError', msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment