Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #1761, add cancel events for tab close, navigate, and reload
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Oct 18, 2016
1 parent ff4f83a commit 6af5637
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions addon/lib/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ const ShotContext = Class({
this.watchTab("pageshow", function (tab) {
// We'll call any pageshow as a sign that at least we reloaded, and should
// stop the pageshot
// FIXME: determine if the notification box is just automatically hidden in this case
sendEvent("cancel-shot", "tab-load");
this.destroy();
});
this.watchTab("close", function () {
// FIXME: determine if the notification box is just automatically hidden in this case
sendEvent("cancel-shot", "tab-close");
this.destroy();
});
this._collectionCompletePromise = new Promise((resolve, reject) => {
Expand Down Expand Up @@ -238,6 +238,10 @@ const ShotContext = Class({
}));
this.interactiveWorker.on("detach", () => {
// Happens if the worker is detached for some reason, such as moving windows
if (! this._destroying) {
// Typically caused by a reload
sendEvent("cancel-shot", "tab-reload");
}
this.destroy();
console.log("the interactive worker was detached");
});
Expand Down Expand Up @@ -304,7 +308,7 @@ const ShotContext = Class({

openInNewTab: function() {
tabs.open(this.shot.viewUrl);
sendEvent("addon", `new-tab-after-save`);
sendEvent(`new-tab-after-save`);
},

/** Collects/extracts information from the tab: the screenshot, readable view,
Expand Down Expand Up @@ -434,6 +438,7 @@ const ShotContext = Class({

/** Renders this object unusable, and unregisters any handlers */
destroy: function () {
this._destroying = true;
if (this._deregisters) {
for (let i=0; i<this._deregisters.length; i++) {
let item = this._deregisters[i];
Expand Down
3 changes: 3 additions & 0 deletions docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ Event label: exactly what control invoked the action, such as toolbar-pageshot-b
3. [x] Click Save `addon/save-shot/overlay-save-button` ![image](https://d17oy1vhnax1f7.cloudfront.net/items/1F021R1U1z0y3A1i0C2F/Image%202016-09-07%20at%202.02.43%20PM.png?v=1c42ee47)
4. [x] Click Cancel `addon/cancel-shot/topbar-cancel` ![image](https://d17oy1vhnax1f7.cloudfront.net/items/3u2M2G1N431s1O193L1n/Image%202016-09-07%20at%202.03.24%20PM.png?v=bedc4e14)
5. [x] Cancel because URL changed `addon/cancel-shot/url-changed` (when something that uses window.history "navigates" spontaneously away)
6. [x] Cancel because the tab is closed `addon/cancel-shot/tab-close`
7. [x] Cancel because the tab is navigated (such as entering something in the URL bar) `addon/cancel-shot/tab-load`
8. [x] Cancel because the tab is reloaded `addon/cancel-shot/tab-reload`
5. [x] Click My Shots `addon/goto-myshots/selection-button` ![image](https://d17oy1vhnax1f7.cloudfront.net/items/3J1u3F1Z3R0Z0A2e161T/Image%202016-09-07%20at%202.06.19%20PM.png?v=7e2c945f)
6. [x] Click on "Save visible" `addon/capture-visible/selection-button`
7. [x] Click on "Save Full Page" `addon/capture-full-page/selection-button`
Expand Down

0 comments on commit 6af5637

Please sign in to comment.