From 1a95d60a3bcc4adeba92c5809bcbe704e47e83d1 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Fri, 13 Sep 2013 00:06:27 -0700 Subject: [PATCH] Remove fetchTimezone from contact model --- clientapp/models/contact.js | 23 +++++------------------ clientapp/pages/chat.js | 1 - 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/clientapp/models/contact.js b/clientapp/models/contact.js index f6e64d0..6ee39bd 100644 --- a/clientapp/models/contact.js +++ b/clientapp/models/contact.js @@ -1,6 +1,7 @@ /*global XMPP, app, me, client*/ //"use strict"; +var _ = require('underscore'); var async = require('async'); var uuid = require('node-uuid'); var HumanModel = require('human-model'); @@ -15,11 +16,11 @@ module.exports = HumanModel.define({ if (attrs.jid) { this.id = attrs.jid; } - this.setAvatar(attrs.avatarID); - this.resources.bind('add remove reset change', this.resourceChange, this); - this.bind('change:lockedResource', this.fetchTimezone, this); + // I don't know why yet, but I need a bound listener to keep things from breaking. + this.bind('change:id', function () {}, this); + this.resources.bind('add remove reset change', this.onResourceChange, this); }, seal: true, type: 'contact', @@ -97,7 +98,6 @@ module.exports = HumanModel.define({ setAvatar: function (id, type) { var self = this; - if (!id) { var gID = crypto.createHash('md5').update(this.jid).digest('hex'); self.avatar = 'https://gravatar.com/avatar/' + gID + '?s=30&d=mm'; @@ -135,7 +135,7 @@ module.exports = HumanModel.define({ } }); }, - resourceChange: function () { + onResourceChange: function () { // Manually propagate change events for properties that // depend on the resources collection. this.resources.sort(); @@ -152,19 +152,6 @@ module.exports = HumanModel.define({ this.chatState = 'gone'; } }, - fetchTimezone: function () { - var self = this; - app.whenConnected(function () { - if (self.lockedResource) { - client.getTime(self.lockedResource, function (err, res) { - if (err) return; - self.timezoneOffset = res.time.tzo; - }); - } else { - self.timezoneOffset = undefined; - } - }); - }, fetchHistory: function () { var self = this; app.whenConnected(function () { diff --git a/clientapp/pages/chat.js b/clientapp/pages/chat.js index a50abf9..3b8cd19 100644 --- a/clientapp/pages/chat.js +++ b/clientapp/pages/chat.js @@ -12,7 +12,6 @@ module.exports = BasePage.extend({ template: templates.pages.chat, initialize: function (spec) { this.editMode = false; - this.model.fetchTimezone(); this.model.fetchHistory(); this.render(); },