зеркало из https://github.com/mozilla/snowl.git
implement 'error' state and visuals for collections tree.
This commit is contained in:
Родитель
198b2745ec
Коммит
508eda2eb4
|
@ -83,3 +83,8 @@
|
|||
*/
|
||||
list-style-image: url("chrome://snowl/content/icons/arrow_refresh_small.png");
|
||||
}
|
||||
|
||||
/* Error on collection indicator */
|
||||
#sourcesViewTreeChildren::-moz-tree-image(hasError) {
|
||||
list-style-image: url("chrome://snowl/content/icons/exclamation.png");
|
||||
}
|
||||
|
|
|
@ -1178,6 +1178,8 @@ function SnowlTreeViewGetCellProperties(aRow, aColumn, aProperties) {
|
|||
aProperties.AppendElement(this._getAtomFor("hasNew"));
|
||||
if (((source && source.busy) || (nodeStats && nodeStats.busy)) && !node.containerOpen)
|
||||
aProperties.AppendElement(this._getAtomFor("isBusy"));
|
||||
if (source && source.error && !node.containerOpen)
|
||||
aProperties.AppendElement(this._getAtomFor("hasError"));
|
||||
|
||||
//if (nodeStats)
|
||||
//SnowlPlaces._log.info("getCellProperties: itemId:title:stats - "+
|
||||
|
@ -1242,9 +1244,11 @@ function SnowlTreeViewGetImageSrc(aRow, aColumn) {
|
|||
let nodeStats = SnowlService.getCollectionStatsByCollectionID()[collID];
|
||||
let source = SnowlService.sourcesByID[query.queryID];
|
||||
|
||||
if ((nodeStats && (nodeStats.n || nodeStats.busy)) || (source && source.busy))
|
||||
// Don't set icon, let css handle it for 'new' or 'busy'. "all" collection
|
||||
// (only) has a busy property so we can set an indicator on a closed container.
|
||||
if ((nodeStats && (nodeStats.n || nodeStats.busy)) ||
|
||||
(source && (source.busy || source.error)))
|
||||
// Don't set icon, let css handle it for 'new' or 'busy' or 'error'.
|
||||
// "all" collection (only) has a busy property so we can set an indicator on
|
||||
// a closed container.
|
||||
return "";
|
||||
|
||||
var icon = node.icon;
|
||||
|
|
|
@ -201,7 +201,7 @@ SnowlFeed.prototype = {
|
|||
refresh: function(time) {
|
||||
if (typeof time == "undefined" || time == null)
|
||||
time = new Date();
|
||||
this._log.info("start refresh " + this.machineURI.spec + " at " + time);
|
||||
// this._log.info("start refresh " + this.machineURI.spec + " at " + time);
|
||||
|
||||
// FIXME: remove subscribe from this notification's name.
|
||||
Observers.notify("snowl:subscribe:connect:start", this);
|
||||
|
@ -218,11 +218,9 @@ SnowlFeed.prototype = {
|
|||
// FIXME: remove subscribe from this notification's name.
|
||||
Observers.notify("snowl:subscribe:connect:end", this, request.status);
|
||||
|
||||
this.lastStatus = request.status + " (" + request.statusText + ")";
|
||||
if (request.status < 200 || request.status > 299 || request.responseText.length == 0) {
|
||||
// XXX Perhaps we should set this._lastStatus = request.status so we don't
|
||||
// need to pass it in this notification and it's available at any time.
|
||||
// XXX Should we throw instead?
|
||||
this._log.error("refresh error: " + request.status + " (" + request.statusText + ")");
|
||||
this.onRefreshError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -263,8 +261,8 @@ SnowlFeed.prototype = {
|
|||
// FIXME: report a more descriptive error message and figure out a better
|
||||
// way to handle this condition.
|
||||
if (result.doc == null) {
|
||||
// XXX Should we throw instead?
|
||||
this._log.error("onRefreshResult: result.doc is null");
|
||||
this.lastStatus = "result.doc is null";
|
||||
this.onRefreshError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -277,8 +277,10 @@ let SnowlService = {
|
|||
let allSources = sources ? sources : this.sources;
|
||||
|
||||
// Set busy property, notify observer to invalidate tree.
|
||||
for each (let source in allSources)
|
||||
for each (let source in allSources) {
|
||||
this.sourcesByID[source.id].busy = true;
|
||||
this.sourcesByID[source.id].error = false;
|
||||
}
|
||||
|
||||
if (allSources.length > 0) {
|
||||
// Don't set busy on 'all' until we know when the last one is done so it
|
||||
|
@ -302,13 +304,15 @@ let SnowlService = {
|
|||
refreshSourceTimer: function(aSource, aRefreshTime) {
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
let callback = { notify: function(aTimer) {
|
||||
SnowlService._log.info("refreshing source " + aSource.name);
|
||||
SnowlService._log.info("Refreshing source: " +
|
||||
aSource.name + " - " + aSource.machineURI.spec);
|
||||
try {
|
||||
aSource.refresh(aRefreshTime);
|
||||
aSource.persist();
|
||||
}
|
||||
catch(ex) {
|
||||
this._log.error("error refreshing source " + aSource.name + ": " + ex);
|
||||
aSource.lastStatus = ex;
|
||||
aSource.onRefreshError();
|
||||
}
|
||||
} };
|
||||
|
||||
|
|
|
@ -195,6 +195,10 @@ SnowlSource.prototype = {
|
|||
// For adding isBusy property to collections tree.
|
||||
busy: false,
|
||||
|
||||
// For adding hasError property to collections tree, status message.
|
||||
error: false,
|
||||
lastStatus: null,
|
||||
|
||||
id: null,
|
||||
|
||||
name: null,
|
||||
|
@ -297,6 +301,13 @@ SnowlSource.prototype = {
|
|||
*/
|
||||
refresh: function(refreshTime) {},
|
||||
|
||||
onRefreshError: function() {
|
||||
this.error = true;
|
||||
SnowlService.sourcesByID[this.id].error = true;
|
||||
Observers.notify("snowl:messages:completed", this.id);
|
||||
this._log.error("Refresh error: " + this.lastStatus);
|
||||
},
|
||||
|
||||
retrieveMessages: function() {
|
||||
// FIXME: memoize this.
|
||||
let messagesStatement = SnowlDatastore.createStatement(
|
||||
|
|
|
@ -302,7 +302,7 @@ SnowlTwitter.prototype = {
|
|||
refresh: function(time) {
|
||||
if (typeof time == "undefined" || time == null)
|
||||
time = new Date();
|
||||
this._log.info("start refresh " + this.username + " at " + time);
|
||||
// this._log.info("start refresh " + this.username + " at " + time);
|
||||
|
||||
Observers.notify("snowl:subscribe:get:start", this);
|
||||
|
||||
|
@ -339,13 +339,12 @@ SnowlTwitter.prototype = {
|
|||
requestHeaders: requestHeaders
|
||||
});
|
||||
|
||||
// FIXME: remove subscribe from this notification's name.
|
||||
Observers.notify("snowl:subscribe:connect:end", this, request.status);
|
||||
|
||||
this.lastStatus = request.status + " (" + request.statusText + ")";
|
||||
if (request.status < 200 || request.status > 299 || request.responseText.length == 0) {
|
||||
// XXX Perhaps we should set this._lastStatus = request.status so we don't
|
||||
// need to pass it in this notification and it's available at any time.
|
||||
// FIXME: remove subscribe from this notification's name.
|
||||
Observers.notify("snowl:subscribe:connect:end", this, request.status);
|
||||
// XXX Should we throw instead?
|
||||
this._log.error("refresh error: " + request.status + " (" + request.statusText + ")");
|
||||
this.onRefreshError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче