Skip to content

Commit f8dfdf1

Browse files
author
leoding86
committed
listen event onDetermingFilename when extension boots
1 parent de031f2 commit f8dfdf1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/background/Application.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ class Application {
8585
* Get settings before doing anything else.
8686
*/
8787
this.settings = await settingService.getSettings();
88+
89+
/**
90+
* Initialize DownloadService here to ensure the event onDetermingFilename has been listened
91+
* when extension boots, otherwise it will occure browser 'save as' delay issue.
92+
*/
93+
this.getService('Download');
8894
}
8995

9096
onBooted() {

src/background/services/DownloadService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DownloadService extends AbstractService {
2424

2525
constructor() {
2626
super();
27-
// this.listenOnDeterminingFilename();
27+
this.listenOnDeterminingFilename();
2828
}
2929

3030
listenOnDeterminingFilename() {
@@ -131,7 +131,7 @@ class DownloadService extends AbstractService {
131131
}
132132

133133
async saveFile({ url, filename }) {
134-
// this.cacheDownloadIdFilename(url, filename);
134+
this.cacheDownloadIdFilename(url, filename);
135135
const downloadId = await FileSystem.getDefault().saveFile({ url, filename });
136136
return downloadId;
137137
}

0 commit comments

Comments
 (0)