Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor cleanup

  • Loading branch information...
commit 5a45fc5581685313b25d7315028c655cac520685 1 parent 799eb13
@gfxmonk gfxmonk authored
Showing with 12 additions and 12 deletions.
  1. +10 −10 app/news-sources.sjs
  2. +1 −1  index.html
  3. +1 −1  templates/columns.html
View
20 app/news-sources.sjs
@@ -40,6 +40,7 @@ var newsFunctions = {
c.par.map(items, function(item) {
using(this.workItem()) {
this.processItem(item);
+ this.items.push(item);
}
}, this);
this.flush_cache();
@@ -68,7 +69,7 @@ var newsFunctions = {
throw new Error(this.type + " items not received within " + Math.round(this.loadTimeout / 1000) + " seconds");
}
}
- var newItems = this.addNewItems(items);
+ var newItems = this.filterNewItems(items);
this.processItems(newItems);
this.appendMethod = 'unshift'; // future items get inserted above existing items
hold(1000 * 60 * 2);
@@ -104,9 +105,8 @@ var newsFunctions = {
};
},
- addNewItems: function(newItems, idProp){
- // adds all new items to this.items, and returns only
- // the items that haven't already been seen
+ filterNewItems: function(newItems, idProp){
+ // returns only the items that haven't already been seen
idProp = idProp || 'id';
var existingItems = this.items;
var existingIds = underscore.pluck(existingItems, idProp);
@@ -122,7 +122,6 @@ var newsFunctions = {
newIds = underscore.difference(newIds, existingIds);
newItems = underscore.select(newItems, function(t) { return underscore.include(newIds, t[idProp]); });
- this.items = existingItems.concat(newItems);
return newItems;
},
@@ -168,14 +167,15 @@ var newsFunctions = {
this.columns[minColumnIndex][this.appendMethod](article);
},
- hideArticle: function(article) {
+ hideArticle: function(article, column) {
logging.debug("hiding article: ", null, article);
this.bg(function() {
article.hidden = true;
- this.cache.save(article);
- c.each(this.columns, function(col) {
- angular.Array.remove(col, article);
- });
+ try {
+ this.cache.save(article);
+ } and {
+ angular.Array.remove(column, article);
+ }
});
},
View
2  index.html
@@ -38,7 +38,7 @@
})());
var logging = require("apollo:logging");
-if(document.location.host.indexOf('127.0.0.1') !== -1) {
+if(document.location.host.indexOf('127.0.0.1') !== -1 || document.location.host.indexOf('localhost') !== -1) {
logging.setLevel(logging.DEBUG);
}
View
2  templates/columns.html
@@ -1,7 +1,7 @@
<!-- common news article layout -->
<div class="col" ng:repeat="col in columns">
<div class="article {{$position}}" ng:repeat="article in col">
- <a class="hide" ng:click="hideArticle(article)">(hide article)</a>
+ <a class="hide" ng:click="hideArticle(article, col)">(hide article)</a>
<div class="inner">
<a ng:href="{{article.url}}">
<h3 ng:show="article.heading.text">{{article.heading.text}}</h3>
Please sign in to comment.
Something went wrong with that request. Please try again.