mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-26 03:02:25 -05:00
Fix roster and timezone info
This commit is contained in:
parent
9491fa6289
commit
9449a00dda
@ -230,8 +230,8 @@ module.exports = function (client, app) {
|
||||
contact.addMessage(message, true);
|
||||
|
||||
if (!contact.lockedResource) {
|
||||
contact.lockedResource = contact.resources.get(msg.from.full);
|
||||
} else if (msg.from.full !== contact.lockedResource.id) {
|
||||
contact.lockedResource = msg.from.full;
|
||||
} else if (msg.from.full !== contact.lockedResource) {
|
||||
contact.lockedResource = undefined;
|
||||
}
|
||||
}
|
||||
|
@ -4689,7 +4689,7 @@ EntityTime.prototype = {
|
||||
}
|
||||
if (formatted.charAt(0) === '-') {
|
||||
sign = 1;
|
||||
formatted.slice(1);
|
||||
formatted = formatted.slice(1);
|
||||
}
|
||||
split = formatted.split(':');
|
||||
hrs = parseInt(split[0], 10);
|
||||
@ -4979,31 +4979,24 @@ WSConnection.prototype.connect = function (opts) {
|
||||
self.parser = new DOMParser();
|
||||
self.serializer = new XMLSerializer();
|
||||
|
||||
try {
|
||||
self.conn = new WebSocket(opts.wsURL, 'xmpp');
|
||||
self.conn.onerror = function (e) {
|
||||
e.preventDefault();
|
||||
console.log(e);
|
||||
self.emit('disconnected', self);
|
||||
return false;
|
||||
};
|
||||
self.conn = new WebSocket(opts.wsURL, 'xmpp');
|
||||
self.conn.onerror = function (e) {
|
||||
e.preventDefault();
|
||||
self.emit('disconnected', self);
|
||||
return false;
|
||||
};
|
||||
|
||||
self.conn.onclose = function () {
|
||||
self.emit('disconnected', self);
|
||||
};
|
||||
self.conn.onclose = function () {
|
||||
self.emit('disconnected', self);
|
||||
};
|
||||
|
||||
self.conn.onopen = function () {
|
||||
self.emit('connected', self);
|
||||
};
|
||||
self.conn.onopen = function () {
|
||||
self.emit('connected', self);
|
||||
};
|
||||
|
||||
self.conn.onmessage = function (wsMsg) {
|
||||
self.emit('raw:incoming', wsMsg.data);
|
||||
};
|
||||
} catch (e) {
|
||||
console.log('Caught exception');
|
||||
return self.emit('disconnected', self);
|
||||
|
||||
}
|
||||
self.conn.onmessage = function (wsMsg) {
|
||||
self.emit('raw:incoming', wsMsg.data);
|
||||
};
|
||||
};
|
||||
|
||||
WSConnection.prototype.disconnect = function () {
|
||||
|
@ -36,11 +36,15 @@ module.exports = HumanModel.define({
|
||||
activeContact: ['bool', true, false],
|
||||
avatar: 'string',
|
||||
chatState: ['string', true, 'gone'],
|
||||
idleSince: 'string',
|
||||
lastInteraction: 'date',
|
||||
lastSentMessage: 'object',
|
||||
lockedResource: 'object',
|
||||
lockedResource: 'string',
|
||||
offlineStatus: ['string', true, ''],
|
||||
topResource: 'object',
|
||||
show: ['string', true, 'offline'],
|
||||
status: ['string', true, ''],
|
||||
timezoneOffset: 'number',
|
||||
topResource: 'string',
|
||||
unreadCount: ['number', true, 0]
|
||||
},
|
||||
derived: {
|
||||
@ -50,58 +54,12 @@ module.exports = HumanModel.define({
|
||||
return this.name || this.jid;
|
||||
}
|
||||
},
|
||||
status: {
|
||||
deps: ['topResource', 'lockedResource', 'offlineStatus'],
|
||||
fn: function () {
|
||||
if (this.lockedResource) {
|
||||
return this.lockedResource.status;
|
||||
}
|
||||
if (this.topResource) {
|
||||
return this.topResource.status;
|
||||
}
|
||||
return this.offlineStatus;
|
||||
}
|
||||
},
|
||||
show: {
|
||||
deps: ['topResource', 'lockedResource'],
|
||||
fn: function () {
|
||||
if (this.lockedResource) {
|
||||
return this.lockedResource.show || 'online';
|
||||
}
|
||||
if (this.topResource) {
|
||||
return this.topResource.show || 'online';
|
||||
}
|
||||
return 'offline';
|
||||
}
|
||||
},
|
||||
idleSince: {
|
||||
deps: ['topResource', 'lockedResource'],
|
||||
fn: function () {
|
||||
if (this.lockedResource) {
|
||||
return this.lockedResource.idleSince;
|
||||
}
|
||||
if (this.topResource) {
|
||||
return this.topResource.idleSince;
|
||||
}
|
||||
}
|
||||
},
|
||||
timezoneOffset: {
|
||||
deps: ['topResource', 'lockedResource'],
|
||||
fn: function () {
|
||||
if (this.lockedResource) {
|
||||
return this.lockedResource.timezoneOffset;
|
||||
}
|
||||
if (this.topResource) {
|
||||
return this.topResource.timezoneOffset;
|
||||
}
|
||||
}
|
||||
},
|
||||
formattedTZO: {
|
||||
deps: ['timezoneOffset', 'displayName'],
|
||||
fn: function () {
|
||||
if (this.timezoneOffset !== undefined) {
|
||||
var localTZO = (new Date()).getTimezoneOffset();
|
||||
var diff = Math.abs(localTZO - this.timezoneOffset) / 60;
|
||||
var diff = Math.abs(localTZO % (24 * 60) - this.timezoneOffset % (24 * 60)) / 60;
|
||||
if (diff === 0) {
|
||||
return this.displayName + ' is in the same timezone as you';
|
||||
}
|
||||
@ -163,6 +121,15 @@ module.exports = HumanModel.define({
|
||||
}
|
||||
});
|
||||
},
|
||||
onLockedResourceChange: function () {
|
||||
var res = this.resources.get(this.lockedResource);
|
||||
if (res) {
|
||||
this.status = res.status;
|
||||
this.show = res.show || 'online';
|
||||
this.timezoneOffset = res.timezoneOffset;
|
||||
this.idleSince = res.idleSince;
|
||||
}
|
||||
},
|
||||
onResourceChange: function () {
|
||||
// Manually propagate change events for properties that
|
||||
// depend on the resources collection.
|
||||
@ -171,10 +138,20 @@ module.exports = HumanModel.define({
|
||||
var res = this.resources.first();
|
||||
if (res) {
|
||||
this.offlineStatus = '';
|
||||
this.topResource = res;
|
||||
this.topResource = res.id;
|
||||
if (!this.lockedResource) {
|
||||
this.status = res.status;
|
||||
this.show = res.show || 'online';
|
||||
this.timezoneOffset = res.timezoneOffset;
|
||||
this.idleSince = res.idleSince;
|
||||
}
|
||||
} else {
|
||||
this.topResource = undefined;
|
||||
this.chatState = 'gone';
|
||||
this.status = this.offlineStatus;
|
||||
this.show = 'offline';
|
||||
this.timezoneOffset = undefined;
|
||||
this.idleSince = undefined;
|
||||
}
|
||||
|
||||
this.lockedResource = undefined;
|
||||
|
@ -27,5 +27,10 @@ module.exports = BasePage.extend({
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
render: function () {
|
||||
this.renderAndBind();
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
@ -13,7 +13,7 @@ exports.pages = {};
|
||||
exports.body = function anonymous(locals) {
|
||||
var buf = [];
|
||||
with (locals || {}) {
|
||||
buf.push('<body><div class="wrap"><aside id="connectionStatus"><button class="reconnect">Reconnect</button><span class="message">disconnected</span></aside><div id="connectionOverlay"></div><header id="me"><img class="avatar"/><p class="status"></p></header><nav class="main"><li><a href="/logout">Logout</a></li><li><a href="/">Home</a></li></nav><nav id="contactList"></nav><section id="pages"></section><footer></footer></div></body>');
|
||||
buf.push('<body><div class="wrap"><div id="connectionOverlay"><aside id="connectionStatus"><button class="reconnect">Reconnect</button><span class="message">disconnected</span></aside></div><header id="me"><img class="avatar"/><p class="status"></p></header><nav class="main"><li><a href="/logout">Logout</a></li><li><a href="/">Home</a></li></nav><nav id="contactList"></nav><section id="pages"></section><footer></footer></div></body>');
|
||||
}
|
||||
return buf.join("");
|
||||
};
|
||||
@ -99,7 +99,7 @@ exports.pages.chat = function anonymous(locals) {
|
||||
exports.pages.main = function anonymous(locals) {
|
||||
var buf = [];
|
||||
with (locals || {}) {
|
||||
buf.push('<section class="page main"><h1>This space intentionally blank</h1><button class="enableAlerts">Enable alerts</button></section>');
|
||||
buf.push('<section class="page main"><button class="enableAlerts">Enable alerts</button><section class="notifications"><h1>Notifications</h1><ul></ul></section></section>');
|
||||
}
|
||||
return buf.join("");
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
body
|
||||
.wrap
|
||||
aside#connectionStatus
|
||||
button.reconnect Reconnect
|
||||
span.message disconnected
|
||||
#connectionOverlay
|
||||
aside#connectionStatus
|
||||
button.reconnect Reconnect
|
||||
span.message disconnected
|
||||
header#me
|
||||
img.avatar
|
||||
p.status
|
||||
|
@ -1,3 +1,6 @@
|
||||
section.page.main
|
||||
h1 This space intentionally blank
|
||||
button.enableAlerts Enable alerts
|
||||
|
||||
section.notifications
|
||||
h1 Notifications
|
||||
ul
|
||||
|
@ -18,7 +18,7 @@
|
||||
"node-uuid": "1.4.1",
|
||||
"semi-static": "0.0.4",
|
||||
"sound-effect-manager": "0.0.5",
|
||||
"human-model": "1.1.2",
|
||||
"human-model": "1.1.3",
|
||||
"human-view": "1.1.2",
|
||||
"templatizer": "0.1.2",
|
||||
"underscore": "1.5.1"
|
||||
|
@ -197,7 +197,7 @@ nav.main a {
|
||||
overflow-x: hidden;
|
||||
position: relative;
|
||||
margin-top: 50px;
|
||||
padding-top: 30px;
|
||||
padding-top: 50px;
|
||||
bottom: 50px;
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ nav.main a {
|
||||
border: 1px solid #a7d9eb;
|
||||
outline: 0px;
|
||||
}
|
||||
#loginbox button, .andyetLogin {
|
||||
button, .andyetLogin {
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
border-radius: 3px;
|
||||
@ -401,3 +401,13 @@ nav.main a {
|
||||
#logo {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.enableAlerts {
|
||||
display: none;
|
||||
}
|
||||
.enableAlerts.shouldAskForAlertsPermission {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user