Skip to content

Commit

Permalink
Merge branch 'fix-reset-history'
Browse files Browse the repository at this point in the history
  • Loading branch information
mika committed Aug 13, 2019
2 parents cc99023 + c147a4f commit 52c591f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
17 changes: 13 additions & 4 deletions src/js/background/clipping-handler-browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const ClippingHandler_Browser = (function(){
const state = {
isListening: false,
createdFilenameDict: T.createDict(), // downloadItemId => filename (full path)
taskFilenameDict: T.createDict(), // downloadItemId => taskFilename
};

Expand Down Expand Up @@ -45,6 +46,13 @@ const ClippingHandler_Browser = (function(){
}).then((downloadItemId) => {
// download started successfully
state.taskFilenameDict.add(downloadItemId, msg.filename);

const createdFilename = state.createdFilenameDict.find(downloadItemId);
if (createdFilename) {
// We've got filename in downloadCreated event if we are in firefox.
// see downloadCreated function.
filenameCreated(downloadItemId, createdFilename);
}
}, (rejectMsg) => {
Log.error(rejectMsg);
SavingTool.taskFailed(msg.filename, errMsg);
Expand All @@ -65,6 +73,7 @@ const ClippingHandler_Browser = (function(){

function downloadCompleted(downloadItemId){
// file that not download through maoxian web clipper
state.createdFilenameDict.remove(downloadItemId);
if(!isDownloadByUs(downloadItemId)) { return false }
ExtApi.findDownloadItem(downloadItemId)
.then((downloadItem) => {
Expand Down Expand Up @@ -117,10 +126,10 @@ const ClippingHandler_Browser = (function(){
if(e.filename){
// firefox has filename on downloadCreated but not in downloadChanged
// download created event is emit before resolve of ExtApi.download
// We deal this event next tick (after ExtApi.download function resolved).
setTimeout(() => {
filenameCreated(e.id, T.sanitizePath(e.filename))
}, 0);
// and we don't know when ExtApi.download will resolve (we can't
// just use setTimeout to delay it. cause it'll unstable)
//
state.createdFilenameDict.add(e.id, T.sanitizePath(e.filename));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

this.ENV = {
logLevel: "debug",
version: '0.1.35',
version: '0.1.36',
minNativeAppVersion: '0.1.9'
};

2 changes: 1 addition & 1 deletion src/js/env.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

this.ENV = {
logLevel: "warn",
version: '0.1.35',
version: '0.1.36',
minNativeAppVersion: '0.1.9'
};

2 changes: 1 addition & 1 deletion src/manifest.chrome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"author": "Mika",
"version": "0.1.35",
"version": "0.1.36",
"default_locale": "en",
"web_accessible_resources": [
"pages/*"
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"author": "Mika",
"version": "0.1.35",
"version": "0.1.36",
"default_locale": "en",
"web_accessible_resources": [
"pages/*"
Expand Down

0 comments on commit 52c591f

Please sign in to comment.