Mercurial > snowl
changeset 117:31fedd0b1466
refactor resetLastRefreshed into a lastRefreshed getter
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Sun, 01 Jun 2008 18:03:18 -0700 |
parents | cb8bbdf99268 |
children | 3c16d71594e5 |
files | extension/modules/feed.js extension/modules/service.js extension/modules/source.js |
diffstat | 3 files changed, 19 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/extension/modules/feed.js Sun Jun 01 17:52:37 2008 -0700 +++ b/extension/modules/feed.js Sun Jun 01 18:03:18 2008 -0700 @@ -76,7 +76,7 @@ onRefreshResult: function(aResult) { // Now that we know we successfully downloaded the feed and obtained // a result from it, update the "last refreshed" timestamp. - this.resetLastRefreshed(this); + this.lastRefreshed = new Date(); let feed = aResult.doc.QueryInterface(Components.interfaces.nsIFeed); @@ -337,22 +337,6 @@ SnowlDatastore.insertMetadatum(aMessageID, attributeID, aValue); }, - /** - * Reset the last refreshed time for the given source to the current time. - * - * XXX should this be setLastRefreshed and take a time parameter - * to set the last refreshed time to? - * - * aSource {SnowlMessageSource} the source for which to set the time - */ - // FIXME: make this a setter for the lastRefreshed property. - resetLastRefreshed: function() { - let stmt = SnowlDatastore.createStatement("UPDATE sources SET lastRefreshed = :lastRefreshed WHERE id = :id"); - stmt.params.lastRefreshed = new Date().getTime(); - stmt.params.id = this.id; - stmt.execute(); - }, - // FIXME: make this accept a callback to which it reports on its progress // so we can provide feedback to the user in subscription interfaces. subscribe: function() {
--- a/extension/modules/service.js Sun Jun 01 17:52:37 2008 -0700 +++ b/extension/modules/service.js Sun Jun 01 18:03:18 2008 -0700 @@ -240,7 +240,7 @@ // period of time. We should instead keep trying when a source fails, // but with a progressively longer interval (up to the standard one). // FIXME: implement the approach described above. - source.resetLastRefreshed(); + source.lastRefreshed = new Date(); } this._obsSvc.notifyObservers(null, "messages:changed", null);
--- a/extension/modules/source.js Sun Jun 01 17:52:37 2008 -0700 +++ b/extension/modules/source.js Sun Jun 01 18:03:18 2008 -0700 @@ -13,7 +13,7 @@ this.name = aName; this.machineURI = aMachineURI; this.humanURI = aHumanURI; - this.lastRefreshed = aLastRefreshed; + this._lastRefreshed = aLastRefreshed; this.importance = aImportance; } @@ -112,7 +112,22 @@ // A JavaScript Date object representing the last time this source // was checked for updates to its set of messages. - lastRefreshed: null, + _lastRefreshed: null, + + get lastRefreshed() { + return this._lastRefreshed; + }, + + set lastRefreshed(newValue) { + this._lastRefreshed = newValue; + + let stmt = SnowlDatastore.createStatement("UPDATE sources " + + "SET lastRefreshed = :lastRefreshed " + + "WHERE id = :id"); + stmt.params.lastRefreshed = this._lastRefreshed.getTime(); + stmt.params.id = this.id; + stmt.execute(); + }, // An integer representing how important this source is to the user // relative to other sources to which the user is subscribed.