mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 17:22:22 -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);
|
contact.addMessage(message, true);
|
||||||
|
|
||||||
if (!contact.lockedResource) {
|
if (!contact.lockedResource) {
|
||||||
contact.lockedResource = contact.resources.get(msg.from.full);
|
contact.lockedResource = msg.from.full;
|
||||||
} else if (msg.from.full !== contact.lockedResource.id) {
|
} else if (msg.from.full !== contact.lockedResource) {
|
||||||
contact.lockedResource = undefined;
|
contact.lockedResource = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4689,7 +4689,7 @@ EntityTime.prototype = {
|
|||||||
}
|
}
|
||||||
if (formatted.charAt(0) === '-') {
|
if (formatted.charAt(0) === '-') {
|
||||||
sign = 1;
|
sign = 1;
|
||||||
formatted.slice(1);
|
formatted = formatted.slice(1);
|
||||||
}
|
}
|
||||||
split = formatted.split(':');
|
split = formatted.split(':');
|
||||||
hrs = parseInt(split[0], 10);
|
hrs = parseInt(split[0], 10);
|
||||||
@ -4979,11 +4979,9 @@ WSConnection.prototype.connect = function (opts) {
|
|||||||
self.parser = new DOMParser();
|
self.parser = new DOMParser();
|
||||||
self.serializer = new XMLSerializer();
|
self.serializer = new XMLSerializer();
|
||||||
|
|
||||||
try {
|
|
||||||
self.conn = new WebSocket(opts.wsURL, 'xmpp');
|
self.conn = new WebSocket(opts.wsURL, 'xmpp');
|
||||||
self.conn.onerror = function (e) {
|
self.conn.onerror = function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log(e);
|
|
||||||
self.emit('disconnected', self);
|
self.emit('disconnected', self);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -4999,11 +4997,6 @@ WSConnection.prototype.connect = function (opts) {
|
|||||||
self.conn.onmessage = function (wsMsg) {
|
self.conn.onmessage = function (wsMsg) {
|
||||||
self.emit('raw:incoming', wsMsg.data);
|
self.emit('raw:incoming', wsMsg.data);
|
||||||
};
|
};
|
||||||
} catch (e) {
|
|
||||||
console.log('Caught exception');
|
|
||||||
return self.emit('disconnected', self);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WSConnection.prototype.disconnect = function () {
|
WSConnection.prototype.disconnect = function () {
|
||||||
|
@ -36,11 +36,15 @@ module.exports = HumanModel.define({
|
|||||||
activeContact: ['bool', true, false],
|
activeContact: ['bool', true, false],
|
||||||
avatar: 'string',
|
avatar: 'string',
|
||||||
chatState: ['string', true, 'gone'],
|
chatState: ['string', true, 'gone'],
|
||||||
|
idleSince: 'string',
|
||||||
lastInteraction: 'date',
|
lastInteraction: 'date',
|
||||||
lastSentMessage: 'object',
|
lastSentMessage: 'object',
|
||||||
lockedResource: 'object',
|
lockedResource: 'string',
|
||||||
offlineStatus: ['string', true, ''],
|
offlineStatus: ['string', true, ''],
|
||||||
topResource: 'object',
|
show: ['string', true, 'offline'],
|
||||||
|
status: ['string', true, ''],
|
||||||
|
timezoneOffset: 'number',
|
||||||
|
topResource: 'string',
|
||||||
unreadCount: ['number', true, 0]
|
unreadCount: ['number', true, 0]
|
||||||
},
|
},
|
||||||
derived: {
|
derived: {
|
||||||
@ -50,58 +54,12 @@ module.exports = HumanModel.define({
|
|||||||
return this.name || this.jid;
|
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: {
|
formattedTZO: {
|
||||||
deps: ['timezoneOffset', 'displayName'],
|
deps: ['timezoneOffset', 'displayName'],
|
||||||
fn: function () {
|
fn: function () {
|
||||||
if (this.timezoneOffset !== undefined) {
|
if (this.timezoneOffset !== undefined) {
|
||||||
var localTZO = (new Date()).getTimezoneOffset();
|
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) {
|
if (diff === 0) {
|
||||||
return this.displayName + ' is in the same timezone as you';
|
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 () {
|
onResourceChange: function () {
|
||||||
// Manually propagate change events for properties that
|
// Manually propagate change events for properties that
|
||||||
// depend on the resources collection.
|
// depend on the resources collection.
|
||||||
@ -171,10 +138,20 @@ module.exports = HumanModel.define({
|
|||||||
var res = this.resources.first();
|
var res = this.resources.first();
|
||||||
if (res) {
|
if (res) {
|
||||||
this.offlineStatus = '';
|
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 {
|
} else {
|
||||||
this.topResource = undefined;
|
this.topResource = undefined;
|
||||||
this.chatState = 'gone';
|
this.chatState = 'gone';
|
||||||
|
this.status = this.offlineStatus;
|
||||||
|
this.show = 'offline';
|
||||||
|
this.timezoneOffset = undefined;
|
||||||
|
this.idleSince = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lockedResource = 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) {
|
exports.body = function anonymous(locals) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
with (locals || {}) {
|
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("");
|
return buf.join("");
|
||||||
};
|
};
|
||||||
@ -99,7 +99,7 @@ exports.pages.chat = function anonymous(locals) {
|
|||||||
exports.pages.main = function anonymous(locals) {
|
exports.pages.main = function anonymous(locals) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
with (locals || {}) {
|
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("");
|
return buf.join("");
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
body
|
body
|
||||||
.wrap
|
.wrap
|
||||||
|
#connectionOverlay
|
||||||
aside#connectionStatus
|
aside#connectionStatus
|
||||||
button.reconnect Reconnect
|
button.reconnect Reconnect
|
||||||
span.message disconnected
|
span.message disconnected
|
||||||
#connectionOverlay
|
|
||||||
header#me
|
header#me
|
||||||
img.avatar
|
img.avatar
|
||||||
p.status
|
p.status
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
section.page.main
|
section.page.main
|
||||||
h1 This space intentionally blank
|
|
||||||
button.enableAlerts Enable alerts
|
button.enableAlerts Enable alerts
|
||||||
|
|
||||||
|
section.notifications
|
||||||
|
h1 Notifications
|
||||||
|
ul
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"node-uuid": "1.4.1",
|
"node-uuid": "1.4.1",
|
||||||
"semi-static": "0.0.4",
|
"semi-static": "0.0.4",
|
||||||
"sound-effect-manager": "0.0.5",
|
"sound-effect-manager": "0.0.5",
|
||||||
"human-model": "1.1.2",
|
"human-model": "1.1.3",
|
||||||
"human-view": "1.1.2",
|
"human-view": "1.1.2",
|
||||||
"templatizer": "0.1.2",
|
"templatizer": "0.1.2",
|
||||||
"underscore": "1.5.1"
|
"underscore": "1.5.1"
|
||||||
|
@ -197,7 +197,7 @@ nav.main a {
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-top: 50px;
|
margin-top: 50px;
|
||||||
padding-top: 30px;
|
padding-top: 50px;
|
||||||
bottom: 50px;
|
bottom: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ nav.main a {
|
|||||||
border: 1px solid #a7d9eb;
|
border: 1px solid #a7d9eb;
|
||||||
outline: 0px;
|
outline: 0px;
|
||||||
}
|
}
|
||||||
#loginbox button, .andyetLogin {
|
button, .andyetLogin {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@ -401,3 +401,13 @@ nav.main a {
|
|||||||
#logo {
|
#logo {
|
||||||
margin: auto;
|
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