зеркало из https://github.com/mozilla/snowl.git
make received constraints work with the non-stored generic MessageCollection objects
This commit is contained in:
Родитель
04dce1d5bd
Коммит
f9f6b5ff6a
|
@ -766,10 +766,8 @@ this._log.info("onMessageAdded: REFRESH RIVER");
|
|||
// parameters: { filter: SnowlUtils.appendAsterisks(SnowlMessageView._filter.value) } });
|
||||
//}
|
||||
|
||||
constraints.push({ name: "received", operator: ">=",
|
||||
value: SnowlDateUtils.jsToJulianDate(this._startTime) });
|
||||
constraints.push({ name: "received", operator: "<=",
|
||||
value: SnowlDateUtils.jsToJulianDate(this._endTime) });
|
||||
constraints.push({ name: "received", operator: ">=", value: this._startTime });
|
||||
constraints.push({ name: "received", operator: "<=", value: this._endTime });
|
||||
|
||||
// Rebuild the view based on the constrained collection.
|
||||
this._rebuildView();
|
||||
|
@ -990,7 +988,7 @@ let Sources = {
|
|||
|
||||
onSelect: function(event) {
|
||||
let item = this._list.selectedItem;
|
||||
|
||||
// FIXME: figure out why item.label is an empty string (XUL bug?).
|
||||
this._log.info("selected item " + item.label +
|
||||
(item.source ? " with source " +
|
||||
(item.source.id ? item.source.id : "")
|
||||
|
|
|
@ -355,7 +355,20 @@ MessageCollection.prototype = {
|
|||
MESSAGES: for each (let message in this.messages) {
|
||||
for each (let { name: name, operator: operator, value: value } in this.constraints) {
|
||||
with (message) {
|
||||
if (!eval(name + operator + value))
|
||||
let propertyValue, satisfies = false;
|
||||
eval("propertyValue = " + name);
|
||||
switch(operator) {
|
||||
case "==":
|
||||
satisfies = (propertyValue == value);
|
||||
break;
|
||||
case "<=":
|
||||
satisfies = (propertyValue <= value);
|
||||
break;
|
||||
case ">=":
|
||||
satisfies = (propertyValue >= value);
|
||||
break;
|
||||
}
|
||||
if (!satisfies)
|
||||
continue MESSAGES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,9 +199,10 @@ SnowlFeed.prototype = {
|
|||
* multiple feeds can give their messages the same received time
|
||||
*/
|
||||
refresh: function(time) {
|
||||
this._log.trace("start refresh");
|
||||
|
||||
if (typeof time == "undefined" || time == null)
|
||||
time = new Date();
|
||||
// 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);
|
||||
|
@ -214,15 +215,18 @@ SnowlFeed.prototype = {
|
|||
// Listen for notification callbacks so we can handle authentication.
|
||||
notificationCallbacks: this
|
||||
});
|
||||
this._log.info("refresh request finished");
|
||||
|
||||
// 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) {
|
||||
this._log.trace("refresh request failed");
|
||||
this.onRefreshError();
|
||||
return;
|
||||
}
|
||||
this._log.trace("refresh request succeeded");
|
||||
|
||||
// _authInfo only gets set if we prompted the user to authenticate
|
||||
// and the user checked the "remember password" box. Since we're here,
|
||||
|
@ -233,6 +237,7 @@ SnowlFeed.prototype = {
|
|||
// Parse the response.
|
||||
// Note: this happens synchronously, even though it uses a listener
|
||||
// callback, which makes it look like it happens asynchronously.
|
||||
this._log.trace("parsing refresh response");
|
||||
let parser = Cc["@mozilla.org/feed-processor;1"].
|
||||
createInstance(Ci.nsIFeedProcessor);
|
||||
parser.listener = {
|
||||
|
@ -246,6 +251,7 @@ SnowlFeed.prototype = {
|
|||
|
||||
this.lastRefreshed = time;
|
||||
|
||||
this._log.trace("end refresh");
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,6 +56,12 @@ let strings = new StringBundle("chrome://snowl/locale/utils.properties");
|
|||
* FIXME: replace this with Datejs <http://www.datejs.com/>.
|
||||
*/
|
||||
let SnowlDateUtils = {
|
||||
get _log() {
|
||||
let log = Log4Moz.repository.getLogger("Snowl.DateUtils");
|
||||
this.__defineGetter__("_log", function() log);
|
||||
return this._log;
|
||||
},
|
||||
|
||||
get msInHour() 1000 * 60 * 60,
|
||||
|
||||
get msInDay() this.msInHour * 24,
|
||||
|
|
Загрузка…
Ссылка в новой задаче