partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 3aea220349b0eb6fa8c787df0ac6eae0491644ae
parent 020158f5f6a992936b5d27bc84d1effb3f65dfaf
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri,  2 Sep 2011 04:57:10 +0200

Fixes:
* Don't display the tip of the day window if no more tips are available
* Display the tip of the day as soon as the relevant stores are loaded

Diffstat:
Mfrontend/js/PartKeepr.js | 35+++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/frontend/js/PartKeepr.js b/frontend/js/PartKeepr.js @@ -52,7 +52,7 @@ Ext.application({ /* Give the user preference stuff enough time to load */ /* @todo Load user preferences directly on login and not via delayed task */ this.displayTipWindowTask = new Ext.util.DelayedTask(this.displayTipOfTheDayWindow, this); - this.displayTipWindowTask.delay(1000); + this.displayTipWindowTask.delay(100); }, /** @@ -62,8 +62,23 @@ Ext.application({ * avoids showing the window. */ displayTipOfTheDayWindow: function () { + if (!this.userPreferenceStore._loaded) { + this.displayTipWindowTask.delay(100); + return; + + } + + if (!this.tipOfTheDayStore._loaded) { + this.displayTipWindowTask.delay(100); + return; + } + if (PartKeepr.getApplication().getUserPreference("partkeepr.tipoftheday.showtips") !== false) { - Ext.create("PartKeepr.TipOfTheDayWindow").show(); + var j = Ext.create("PartKeepr.TipOfTheDayWindow"); + + if (j.getLastUnreadTip() !== null) { + j.show(); + } } }, logout: function () { @@ -132,16 +147,28 @@ Ext.application({ { model: 'PartKeepr.TipOfTheDay', pageSize: -1, - autoLoad: true + autoLoad: true, + listeners: { + scope: this, + load: this.storeLoaded + } }); this.userPreferenceStore = Ext.create("Ext.data.Store", { model: 'PartKeepr.UserPreference', pageSize: -1, - autoLoad: true + autoLoad: true, + listeners: { + scope: this, + load: this.storeLoaded + } }); }, + storeLoaded: function (store) { + console.log("FOO"); + store._loaded = true; + }, setAdmin: function (admin) { this.admin = admin; },