Skip to content
This repository has been archived by the owner on Apr 12, 2018. It is now read-only.

Commit

Permalink
Closes #63 adding history items in real time. This doesn't update tho…
Browse files Browse the repository at this point in the history
…se items with the favicon or meta data since its not ready at that time. We would need to add a page listener for when the meta data is retrieved to get that.
  • Loading branch information
clarkbw committed Mar 5, 2014
1 parent d7a5d4d commit cba667c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 7 additions & 4 deletions data/js/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,14 @@ var Application = Backbone.View.extend({

// this will help get single history additions
addon.on("history:add", function(item) {
var hi;
if (item) {
console.log("ITEM", item);
hl.add(new HistoryItem(item));
} else {
console.log("NOT ITEM", item);
hi = hl.findWhere({ url : item.url });
if (!hi) {
hl.add(new HistoryItem(item));
} else {
hi.set(item);
}
}
});

Expand Down
6 changes: 5 additions & 1 deletion lib/history/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ const nsIHistory = Class({
Ci.nsINavHistoryObserver
]),
onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID, aTransitionType) {
emit(this, "visit", { url : aURI.spec, time : Math.floor(aTime / 1000), title : history.getPageTitle(aURI) });
// ignore redirects
if (aTransitionType === history.TRANSITION_REDIRECT_TEMPORARY || history.TRANSITION_REDIRECT_PERMANENT) {
return;
}
emit(this, "visit", { url : aURI.spec, time : Math.floor(aTime / 1000), title : history.getPageTitle(aURI) || "" });
},
onBeginUpdateBatch: function () {},
onEndUpdateBatch: function () {},
Expand Down
9 changes: 9 additions & 0 deletions lib/page/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ on(History, 'delete', data => {
page.emit('history:removed', data);
});

on(History, 'visit', data => {
page.emit('history:add', data);
});

on(History, 'title:changed', data => {
// history will check for dupes
page.emit('history:add', data);
});

page.on("history:events:delete", ({ message: url }) => {
// remove actual history
remove(url);
Expand Down

0 comments on commit cba667c

Please sign in to comment.