Skip to content

Commit

Permalink
Display result of removing/stripping only once
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Nov 15, 2017
1 parent 2678cb6 commit 1304667
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog for squashmount

*bookmarkdupes-2.1
Martin Väth <martin at mvath.de>:
- Display result of removing/stripping only once

*bookmarkdupes-2.0
Martin Väth <martin at mvath.de>:
- Continue removing/stripping in background if popup is closed,
Expand Down
28 changes: 11 additions & 17 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,9 @@
* This project is under the GNU public license 2.0
*/

let state = {
mode: "virgin"
};
let state;
let stop;

/*
function debug(msg) {
let s = {
mode: "debug",
debug: msg
}
let message = {
command: "state",
state: s
};
browser.runtime.sendMessage(message);
}
*/

function removeFolder(id, callback, errorCallback) {
return browser.bookmarks.remove(id).then(callback, errorCallback);
}
Expand Down Expand Up @@ -90,6 +74,12 @@ function processMarked(remove, removeList) {
processRecurse();
}

function setVirginState() {
state = {
mode: "virgin"
};
}

function sendState() {
let message = {
command: "state",
Expand All @@ -106,6 +96,9 @@ function messageListener(message) {
case "stop":
stop = true;
return;
case "finish":
setVirginState();
// fallthrough
case "sendState":
sendState();
return;
Expand All @@ -118,4 +111,5 @@ function messageListener(message) {
}
}

setVirginState();
browser.runtime.onMessage.addListener(messageListener);
20 changes: 8 additions & 12 deletions data/panel/dupes.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,10 @@ function displayFinish(textId, state) {
if (state.error) {
displayMessage(browser.i18n.getMessage(textId,
[state.error, String(state.total)]));
return;
} else {
displayMessage(browser.i18n.getMessage(textId, String(state.total)));
}
displayMessage(browser.i18n.getMessage(textId, String(state.total)));
sendMessageCommand("finish");
}

{
Expand Down Expand Up @@ -506,26 +507,21 @@ function displayFinish(textId, state) {
displayProgress("messageStripProgress", "buttonStopStripping", state);
return;
case "virgin":
break;
unlock();
return;
case "removeSuccess":
displayFinish("messageRemoveSuccess", state);
break;
return;
case "stripSuccess":
displayFinish("messageStripSuccess", state);
break;
return;
case "removeError":
displayFinish("messageRemoveError", state);
break;
return;
case "stripError":
displayFinish("messageStripError", state);
break;
case "debug":
displayMessage(state.debug);
break;
default: // should not happen
return;
}
unlock();
}

browser.runtime.onMessage.addListener(messageListener);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "bookmarkdupes",
"description": "__MSG_extensionDescription__",
"author": "Martin Väth",
"version": "2.0",
"version": "2.1",
"manifest_version": 2,
"homepage_url": "https://github.com/vaeth/bookmarkdupes.git",
"default_locale": "en",
Expand Down

0 comments on commit 1304667

Please sign in to comment.