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 @@ ...@@ -146,11 +146,13 @@
}).then(function () { }).then(function () {
const view = _converse.chatboxviews.get(contact_jid); const view = _converse.chatboxviews.get(contact_jid);
const toolbar = view.el.querySelector('.chat-toolbar'); const toolbar = view.el.querySelector('.chat-toolbar');
expect(view.model.get('omemo_active')).toBe(undefined);
expect(_.isNull(toolbar.querySelector('.toggle-omemo'))).toBe(false); expect(_.isNull(toolbar.querySelector('.toggle-omemo'))).toBe(false);
spyOn(view, 'toggleOMEMO').and.callThrough(); spyOn(view, 'toggleOMEMO').and.callThrough();
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
toolbar.querySelector('.toggle-omemo').click(); toolbar.querySelector('.toggle-omemo').click();
expect(view.toggleOMEMO).toHaveBeenCalled(); expect(view.toggleOMEMO).toHaveBeenCalled();
expect(view.model.get('omemo_active')).toBe(true);
done(); done();
}).catch(_.partial(console.error, _)); }).catch(_.partial(console.error, _));
})); }));
......
...@@ -328,18 +328,16 @@ ...@@ -328,18 +328,16 @@
}, },
getOutgoingMessageAttributes (text, spoiler_hint) { getOutgoingMessageAttributes (text, spoiler_hint) {
const fullname = _converse.xmppstatus.get('fullname'), const is_spoiler = this.get('composing_spoiler');
is_spoiler = this.get('composing_spoiler'); return _.extend(this.toJSON(), {
'fullname': _converse.xmppstatus.get('fullname'),
return {
'fullname': fullname,
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'sender': 'me', 'sender': 'me',
'time': moment().format(), 'time': moment().format(),
'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined, 'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined,
'is_spoiler': is_spoiler, 'is_spoiler': is_spoiler,
'spoiler_hint': is_spoiler ? spoiler_hint : undefined 'spoiler_hint': is_spoiler ? spoiler_hint : undefined
}; });
}, },
sendMessage (attrs) { sendMessage (attrs) {
......
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
}, },
toggleOMEMO (ev) { toggleOMEMO (ev) {
// TODO:
ev.preventDefault(); ev.preventDefault();
this.model.save({'omemo_active': !this.model.get('omemo_active')});
} }
} }
}, },
......
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
this.trigger('showReceivedOTRMessage', msg); this.trigger('showReceivedOTRMessage', msg);
}); });
this.otr.on('io', (msg) => { this.otr.on('io', (msg) => {
this.sendMessage(new _converse.Message({'message':msg})); this.sendMessage({'message':msg});
}); });
this.otr.on('error', (msg) => { this.otr.on('error', (msg) => {
this.trigger('showOTRError', 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