Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Fixed content source toggle bug
Fixed refreshing of settings, history, bookmarks and feeds
Fixed missing icon image from delete modal
  • Loading branch information
CptFoobar committed Dec 6, 2015
1 parent 57544d3 commit a2dad8a
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 87 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -21,7 +21,7 @@ List of targets for v1:
* Home
- ~~Clock~~
- ~~Greeting~~
- Weather
- ~~(moved to v2) Weather~~
- ~~Nav~~


Expand All @@ -33,8 +33,8 @@ List of targets for v1:
* Settings Options
- ~~_Greeting_ : Show greeting~~
- ~~_Name_ : Input user name for greeting~~
- _Location_ : Use automatic/manual location
- _Weather_ : C/F
- ~~(X) _Location_ : Use automatic/manual location~~
- ~~_(X) Weather_ : C/F~~
- ~~(X) _Theme_ : Set dark/light theme~~
- ~~_Feed content_ :~~
~~<-- Latest only -- Latest > Trending -- Balanced -- Trending > Latest -- Trending only -->~~
Expand All @@ -52,8 +52,8 @@ List of targets for v1:

* Other Views
- ~~_Help_ : How to use Blink~~
- _About_ : About Blink (ahem, and me)
- _Support_: $$$ = <3
- ~~_About_ : About Blink (ahem, and me)~~
- ~~_Support_: $$$ = <3~~

* Misc
- [Isotope and packery](http://desandro.com/masonry)
- ~~(moved to v2) [Isotope and packery](http://desandro.com/masonry)~~
2 changes: 0 additions & 2 deletions data/js/MigrationHandler.js
Expand Up @@ -12,7 +12,6 @@ var parseFeedSource = function(json, wanted) {
sourceObject.deliciousTags : [],
wanted: wanted
};
//console.log("parsed: " + JSON.stringify(parsedSource));
return parsedSource;
};

Expand All @@ -23,7 +22,6 @@ const migrate = function(oldPrefs) {
var searchUrlPrefix = "https://cloud.feedly.com/v3/search/feeds?q=";
for (let i = 0; i < oldPrefs.length; i++) {
let url = searchUrlPrefix + oldPrefs[i].link;
console.log("url is: " + url);
Request({
url: url,
onComplete: function(response) {
Expand Down
7 changes: 3 additions & 4 deletions data/js/bookmarksManager.js
Expand Up @@ -5,10 +5,7 @@
self.port.on("bookmarks", function(bookmarksTree) {
bookmarks = bookmarksTree;
});
// If bookmarks is empty, ping the add-on process to get it
if (bookmarks.length == 0)
self.port.emit("getBookmarks", {});


/* Wrapper for fetching all bookmarks */
var fetchBookmarks = function(timeout) {
// Wait for `timeout` secs before declaring 'fetch failure'
Expand Down Expand Up @@ -38,6 +35,8 @@
var intent = message.intent;
switch (intent) {
case "fetch":
bookmarks = [];
self.port.emit("getBookmarks", {});
fetchBookmarks(3);
break;
}
Expand Down
15 changes: 11 additions & 4 deletions data/js/contentManager.js
Expand Up @@ -5,10 +5,7 @@
self.port.on("contentList", function(content) {
contentList = content;
});
// If contentList is empty, ping the add-on process to get it
if (contentList.length == 0)
self.port.emit("getContentList", {});


// FIXME: DRY in managers
// The code below this line (fetchcontentList and the window listener)
// is being repeated in every *Manager.js file. Maybe we can move this
Expand Down Expand Up @@ -62,6 +59,10 @@
self.port.emit("deleteSourceItem", item);
}

var toggleSourceItem = function(item) {
self.port.emit("toggleSourceItem", item);
}

/* Listen for window message events, and process accordingly. */
window.addEventListener('message', function(event) {
var message = JSON.parse(event.data);
Expand All @@ -71,6 +72,8 @@
switch (intent) {
case "fetch":
console.log("fetch request");
contentList = [];
self.port.emit("getContentList", {});
fetchContentList(3);
break;
case "search":
Expand All @@ -85,6 +88,10 @@
console.log("delete request");
deleteSourceItem(message.payload.removeItem);
break;
case "toggle":
console.log("toggle request");
toggleSourceItem(message.payload.toggleItem)
break;
}
}
}, false);
Expand Down
20 changes: 15 additions & 5 deletions data/js/controllers/ContentController.js
Expand Up @@ -16,9 +16,19 @@
$scope.alerts.splice(index, 1);
};

$scope.updatePrefs = function(msg) {
console.log('toggled ' + msg);
}
$scope.updatePrefs = function(item) {
console.log("toggling " + item.title);
$scope.$emit(
'$messageOutgoing',
angular.toJson({
target: "ContentManager",
intent: "toggle",
payload: {
toggleItem: item
}
})
);
};

$scope.deleteItem = function(item) {
console.log('deleting ' + JSON.stringify(item));
Expand Down Expand Up @@ -98,8 +108,8 @@
};


$scope.promptDelete = function(idToDelete) {

$scope.promptDelete = function(item) {
var idToDelete = indexOf(item);
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'confirmDelete.html',
Expand Down
6 changes: 4 additions & 2 deletions data/js/feedHandler.js
Expand Up @@ -29,7 +29,8 @@
// 'Load More' loader)
console.log("fetching streams...");
for (i = 0; i < feedList.length; i++) {
fetchById(feedList[i], streamUrlPrefix, count);
if (feedList[i].wanted)
fetchById(feedList[i], streamUrlPrefix, count);
}
};

Expand All @@ -40,7 +41,8 @@
// 'Load More' loader)
console.log("fetching trends...");
for (i = 0; i < feedList.length; i++) {
fetchById(feedList[i], trendingUrlPrefix, count);
if (feedList[i].wanted)
fetchById(feedList[i], trendingUrlPrefix, count);
}
};

Expand Down
6 changes: 2 additions & 4 deletions data/js/feedManager.js
Expand Up @@ -16,10 +16,6 @@
else feedRatio = 1;
});

// If feedList is empty, ping the add-on process to get it
if(feedList.length == 0)
self.port.emit("getFeed", {});

/* Wrapper for fetching all feed */
var fetchAllFeed = function(timeout) {
// Wait for `timeout` secs before declaring 'fetch failure'
Expand Down Expand Up @@ -47,6 +43,8 @@
switch (intent) {
case "fetch":
feedRatio = -1;
feedList = [];
self.port.emit("getFeed", {});
self.port.emit("getFeedConfig", {});
fetchAllFeed(4);
break;
Expand Down
6 changes: 2 additions & 4 deletions data/js/historyManager.js
Expand Up @@ -10,10 +10,6 @@
history = recents;
});

// If history is empty, ping the add-on process to get it
if (history.length === 0)
self.port.emit("getHistory", {});

/* Wrapper for fetching all history */
var fetchHistory = function(timeout) {
// Wait for `timeout` secs before declaring 'fetch failure'
Expand Down Expand Up @@ -75,6 +71,8 @@
var intent = message.intent;
switch (intent) {
case "fetch":
history = [];
self.port.emit("getHistory", {});
fetchHistory(3);
break;
}
Expand Down
6 changes: 2 additions & 4 deletions data/js/settingsManager.js
Expand Up @@ -6,10 +6,6 @@
userSettings = content;
});

// If userSettings is empty, ping the add-on process to get it
if (userSettings.length == 0)
self.port.emit("getUserSettings", {});

/* Wrapper for fetching all userSettings */
var fetchUserSettings = function(timeout) {
// Wait for `timeout` secs before declaring 'fetch failure'
Expand Down Expand Up @@ -46,6 +42,8 @@
switch (intent) {
case "getConfig":
console.log("fetch user settings request");
userSettings = [];
self.port.emit("getUserSettings", {});
fetchUserSettings(3);
break;
case "saveConfig":
Expand Down
6 changes: 3 additions & 3 deletions data/markup/content.html
Expand Up @@ -29,7 +29,7 @@
<script type="text/ng-template" id="confirmDelete.html">
<div class="modal-header">
<span class="modal-title delete-confirm-title"> Delete {{ toDelete.title }} ?
<img ng-src="{{ toDelete.image }}" class="src-img"/>
<img ng-src="{{ toDelete.icon }}" class="src-img"/>
</span>
</div>
<div class="modal-body delete-confirm-body">
Expand Down Expand Up @@ -79,10 +79,10 @@
<div class="column col-xs-8 col-sm-3 col-md-2 col-md-push-1 content-wrapper" ng-repeat="i in [] | range:getColumns()">
<div class="item-container noselect" ng-repeat="src in items | orderBy:'title'" ng-if="$index % getColumns() === i">
<span>
<h5><span class="delete-button" ng-click="promptDelete($index)"><i class="fa fa-trash fa-fw fa-lg"></i></span></h5>
<h5><span class="delete-button" ng-click="promptDelete(src)"><i class="fa fa-trash fa-fw fa-lg"></i></span></h5>
<img ng-src="{{ src.icon }}" class="feed-icon" />
<p class="text-center">
<input type="checkbox" style="vertical-align: text-top;" ng-model="src.wanted" ng-click="updatePrefs(src.wanted)">
<input type="checkbox" style="vertical-align: text-top;" ng-model="src.wanted" ng-click="updatePrefs(src)">
<a ng-href="{{ src.websiteUrl }}">{{ src.title }}</a>
</p>
</span>
Expand Down
58 changes: 9 additions & 49 deletions index.js
Expand Up @@ -178,6 +178,13 @@ function setPageMods() {
updateFeed();
}
});
worker.port.on("toggleSourceItem", function(item) {
var index = indexOf(item);
if (index >= 0) {
feedList[index].wanted = !feedList[index].wanted;
updateFeed();
}
});
}
}));

Expand All @@ -202,7 +209,6 @@ function setPageMods() {
function initConfig() {
if (self.loadReason == "install" || self.loadReason == "upgrade"
|| !ss.storage.feedList) {
//makeFeed();
userSettings = {
showGreeting: true,
userName: "Emma",
Expand All @@ -214,53 +220,7 @@ function initConfig() {
userSettings = ss.storage.userSettings;
}

ss.storage.feedprefs = [{
"name" : "TechCrunch",
"link" : "http://feeds.feedburner.com/Techcrunch",
"wanted" : true
},
{
"name" : "Gizmodo",
"link" : "http://feeds.gawker.com/gizmodo/full",
"wanted" : true
},
{
"name" : "Engadget",
"link" : "http://www.engadget.com/rss.xml",
"wanted" : true
},
{
"name" : "LifeHacker",
"link" : "http://feeds.gawker.com/lifehacker/vip",
"wanted" : true
},
{
"name" : "The Verge",
"link" : "http://www.theverge.com/rss/index.xml",
"wanted" : true
},
{
"name" : "Mashable",
"link" : "http://feeds.mashable.com/mashable/tech",
"wanted" : false
},
{
"name" : "Wired",
"link" : "http://feeds.wired.com/wired/index",
"wanted" : true
},
{
"name" : "The Next Web",
"link" : "http://thenextweb.com/feed/",
"wanted" : false
},{
"name" : "// TODO",
"link" : "http://blog.championswimmer.in/feed.xml",
"wanted" : true
}];

//if (self.loadReason == "upgrade") {
if(true) {
if (self.loadReason == "upgrade") {
feedList = MigrationHandler.migrate(ss.storage.feedprefs);
updateFeed();
delete ss.storage.feedprefs;
Expand Down Expand Up @@ -324,7 +284,7 @@ function updateFeed() {
function updateUserSettings(newSettings) {
ss.storage.userSettings = newSettings;
userSettings = newSettings;
console.log("updated. new settings are: " + JSON.stringify(userSettings));
Log("updated. new settings are: " + JSON.stringify(userSettings));
}

/* fetch bookmarks */
Expand Down

0 comments on commit a2dad8a

Please sign in to comment.