1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-11-12 04:25:05 -05:00

Simplify some more. Display is broken until views bind classes properly

This commit is contained in:
Lance Stout 2013-09-13 00:53:13 -07:00
parent d1a74ee411
commit e5a0245639
3 changed files with 25 additions and 24 deletions

View File

@ -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 = msg.from.full; contact.lockedResource = contact.resources.get(msg.from.full);
} else if (msg.from.full !== contact.lockedResource) { } else if (msg.from.full !== contact.lockedResource.id) {
contact.lockedResource = undefined; contact.lockedResource = undefined;
} }
} }

View File

@ -1,5 +1,5 @@
/*global XMPP, app, me, client*/ /*global XMPP, app, me, client*/
//"use strict"; "use strict";
var _ = require('underscore'); var _ = require('underscore');
var async = require('async'); var async = require('async');
@ -23,25 +23,25 @@ module.exports = HumanModel.define({
type: 'contact', type: 'contact',
props: { props: {
id: ['string', true, false], id: ['string', true, false],
avatarID: ['string', true, ''],
groups: ['array', true, []],
inRoster: ['bool', true, false], inRoster: ['bool', true, false],
owner: ['string', true, ''],
storageId: ['string', true, ''],
jid: ['string', true], jid: ['string', true],
name: ['string', true, ''], name: ['string', true, ''],
subscription: ['string', true, 'none'], owner: ['string', true, ''],
groups: ['array', true, []], storageId: ['string', true, ''],
avatarID: ['string', true, ''] subscription: ['string', true, 'none']
}, },
session: { session: {
topResource: 'string', activeContact: ['bool', true, false],
lockedResource: 'string',
offlineStatus: ['string', true, ''],
avatar: 'string', avatar: 'string',
chatState: ['string', true, 'gone'], chatState: ['string', true, 'gone'],
lastInteraction: 'date',
lastSentMessage: 'object', lastSentMessage: 'object',
activeContact: ['bool', true, false], lockedResource: 'object',
unreadCount: ['number', true, 0], offlineStatus: ['string', true, ''],
lastInteraction: 'date' topResource: 'object',
unreadCount: ['number', true, 0]
}, },
derived: { derived: {
displayName: { displayName: {
@ -54,10 +54,10 @@ module.exports = HumanModel.define({
deps: ['topResource', 'lockedResource', 'offlineStatus'], deps: ['topResource', 'lockedResource', 'offlineStatus'],
fn: function () { fn: function () {
if (this.lockedResource) { if (this.lockedResource) {
return this.resources.get(this.lockedResource).status; return this.lockedResource.status;
} }
if (this.topResource) { if (this.topResource) {
return this.resources.get(this.topResource).status; return this.topResource.status;
} }
return this.offlineStatus; return this.offlineStatus;
} }
@ -66,10 +66,10 @@ module.exports = HumanModel.define({
deps: ['topResource', 'lockedResource'], deps: ['topResource', 'lockedResource'],
fn: function () { fn: function () {
if (this.lockedResource) { if (this.lockedResource) {
return this.resources.get(this.lockedResource).show || 'online'; return this.lockedResource.show || 'online';
} }
if (this.topResource) { if (this.topResource) {
return this.resources.get(this.topResource).show || 'online'; return this.topResource.show || 'online';
} }
return 'offline'; return 'offline';
} }
@ -78,10 +78,10 @@ module.exports = HumanModel.define({
deps: ['topResource', 'lockedResource'], deps: ['topResource', 'lockedResource'],
fn: function () { fn: function () {
if (this.lockedResource) { if (this.lockedResource) {
return this.resources.get(this.lockedResource).idleSince; return this.lockedResource.idleSince;
} }
if (this.topResource) { if (this.topResource) {
return this.resources.get(this.topResource).idleSince; return this.topResource.idleSince;
} }
} }
}, },
@ -89,10 +89,10 @@ module.exports = HumanModel.define({
deps: ['topResource', 'lockedResource'], deps: ['topResource', 'lockedResource'],
fn: function () { fn: function () {
if (this.lockedResource) { if (this.lockedResource) {
return this.resources.get(this.lockedResource).timezoneOffset; return this.lockedResource.timezoneOffset;
} }
if (this.topResource) { if (this.topResource) {
return this.resources.get(this.topResource).timezoneOffset; return this.topResource.timezoneOffset;
} }
} }
}, },
@ -171,8 +171,9 @@ 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.id; this.topResource = res;
} else { } else {
this.topResource = undefined;
this.chatState = 'gone'; this.chatState = 'gone';
} }

View File

@ -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.0", "human-model": "1.1.1",
"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"