Mercurial > snowl
changeset 329:e217720a7da8
rebuild the river and stream views at midnight so the period-based groups stay accurate
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Thu, 16 Oct 2008 19:11:46 -0700 |
parents | 081793c751c5 |
children | 58467ce8f44a |
files | content/river.js content/stream.js |
diffstat | 2 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/content/river.js Thu Oct 16 16:38:10 2008 -0700 +++ b/content/river.js Thu Oct 16 19:11:46 2008 -0700 @@ -250,6 +250,8 @@ //this._collection = new SnowlCollection(); this._updateToolbar(); //this.writeContent(); + + this._setMidnightTimout(); }, /** @@ -269,6 +271,14 @@ window.innerHeight - (this.scrollbarWidth*2) - toolbarHeight; }, + _setMidnightTimout: function() { + let t = this; + let now = new Date(); + let msUntilMidnight = SnowlUtils.tomorrow - now; + this._log.info("setting midnight timeout for " + new Date(now.getTime() + msUntilMidnight)); + window.setTimeout(function() { t.onMidnight() }, msUntilMidnight); + }, + //**************************************************************************// // Toolbar @@ -463,6 +473,11 @@ //**************************************************************************// // Event Handlers + onMidnight: function() { + this._setMidnightTimout(); + this.rebuildView(); + }, + doPageMove: function(direction) { this.doMove(direction * this.viewableWidth); },
--- a/content/stream.js Thu Oct 16 16:38:10 2008 -0700 +++ b/content/stream.js Thu Oct 16 19:11:46 2008 -0700 @@ -170,6 +170,16 @@ this._collection.sortOrder = -1; this._collection.sort(); this._rebuildView(); + + this._setMidnightTimout(); + }, + + _setMidnightTimout: function() { + let t = this; + let now = new Date(); + let msUntilMidnight = SnowlUtils.tomorrow - now; + this._log.info("setting midnight timeout for " + new Date(now.getTime() + msUntilMidnight)); + window.setTimeout(function() { t.onMidnight() }, msUntilMidnight); }, @@ -185,6 +195,11 @@ } }, + onMidnight: function() { + this._setMidnightTimout(); + this._rebuildView(); + }, + /** * Resize the content in the middle column based on the width of the viewport. * FIXME: file a bug on the problem that necessitates this hack.