1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-22 17:22:22 -05:00

Make MUC join/leave buttons toggle

This commit is contained in:
Lance Stout 2013-12-16 10:06:03 -08:00
parent 2ca32ca3bd
commit 2d07337967
6 changed files with 40 additions and 5 deletions

View File

@ -176,6 +176,11 @@ module.exports = function (client, app) {
} }
resource.fetchTimezone(); resource.fetchTimezone();
} }
var muc = pres.muc || {};
if (muc.codes && muc.codes.indexOf('110') >= 0) {
contact.joined = true;
}
} }
}); });
@ -195,6 +200,10 @@ module.exports = function (client, app) {
contact.resources.remove(resource); contact.resources.remove(resource);
} }
var muc = pres.muc || {};
if (muc.codes && muc.codes.indexOf('110') >= 0) {
contact.joined = false;
}
} }
}); });
@ -223,7 +232,6 @@ module.exports = function (client, app) {
var resource = contact.resources.get(info.from.full); var resource = contact.resources.get(info.from.full);
if (resource) { if (resource) {
resource.chatState = info.chatState; resource.chatState = info.chatState;
console.log(info.chatState);
if (info.chatState === 'gone') { if (info.chatState === 'gone') {
contact.lockedResource = undefined; contact.lockedResource = undefined;
} else { } else {
@ -393,7 +401,6 @@ module.exports = function (client, app) {
}); });
client.on('jingle:remotestream:added', function (session) { client.on('jingle:remotestream:added', function (session) {
console.log('remote stream', session);
var contact = me.getContact(session.peer); var contact = me.getContact(session.peer);
if (!contact) { if (!contact) {
contact = new Contact({jid: client.JID(session.peer).bare}); contact = new Contact({jid: client.JID(session.peer).bare});

View File

@ -22,7 +22,7 @@ module.exports = HumanModel.define({
deps: ['discoInfo'], deps: ['discoInfo'],
fn: function () { fn: function () {
if (!this.discoInfo) return false; if (!this.discoInfo) return false;
var features = this.discoInfo.features; var features = this.discoInfo.features || [];
return features.indexOf('http://jabber.org/protocol/chatstate') >= 0; return features.indexOf('http://jabber.org/protocol/chatstate') >= 0;
} }
}, },

View File

@ -30,6 +30,9 @@ module.exports = BasePage.extend(chatHelpers).extend({
'click .joinRoom': 'handleJoin', 'click .joinRoom': 'handleJoin',
'click .leaveRoom': 'handleLeave' 'click .leaveRoom': 'handleLeave'
}, },
classBindings: {
joined: '.controls'
},
srcBindings: { srcBindings: {
avatar: 'header .avatar' avatar: 'header .avatar'
}, },

View File

@ -897,6 +897,18 @@ button.secondary:hover:not(:disabled) {
.conversation header .controls { .conversation header .controls {
float: right; float: right;
} }
.conversation header .controls .leaveRoom {
display: none;
}
.conversation header .controls .joinRoom {
display: block;
}
.conversation header .joined .joinRoom {
display: none;
}
.conversation header .joined .leaveRoom {
display: block;
}
.conversation header .avatar { .conversation header .avatar {
margin-right: 5px; margin-right: 5px;
width: 30px; width: 30px;

View File

@ -27,6 +27,19 @@
.controls .controls
float: right float: right
.leaveRoom
display: none
.joinRoom
display: block
.joined
.joinRoom
display: none
.leaveRoom
display: block
.avatar .avatar
margin-right: 5px margin-right: 5px
avatar() avatar()

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# 0.0.1 1386980007554 # 0.0.1 1387217113439
CACHE: CACHE:
/app.js /app.js