Skip to content

Commit 44424cd

Browse files
committed
fix: use adsjs entrypoint for messaging
1 parent 1dc1b6a commit 44424cd

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

injected/scripts/entry-points.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const builds = {
3232
output: ['../build/android/brokerProtection.js'],
3333
},
3434
'android-autofill-import': {
35-
input: 'entry-points/android.js',
35+
input: 'entry-points/android-adsjs.js',
3636
output: ['../build/android/autofillImport.js'],
3737
},
3838
'android-adsjs': {

injected/src/features/autofill-import.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ export default class AutofillImport extends ActionExecutorMixin(ContentFeature)
493493
return;
494494
}
495495
this.#processingBookmark = true;
496-
this.handleBookmarkImportPath(pathname);
496+
await this.handleBookmarkImportPath(pathname);
497497
} else if (this.getFeatureSetting('settingsButton')) {
498498
await this.handlePasswordManagerPath(pathname);
499499
} else {
@@ -596,7 +596,7 @@ export default class AutofillImport extends ActionExecutorMixin(ContentFeature)
596596
await this.storeExportId();
597597
}
598598

599-
await this.processActionAndNotify(action, {}, this.messaging, this.retryConfig);
599+
await this.processActionAndNotify(action, {}, this.retryConfig);
600600
}
601601
this.downloadData();
602602
}

injected/src/features/broker-protection.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ import { execute } from './broker-protection/execute.js';
33
import { retry } from '../timer-utils.js';
44
import { ErrorResponse } from './broker-protection/types.js';
55

6-
export function ActionExecutorMixin(BaseClass) {
7-
return class Mixin extends BaseClass {
8-
async processActionAndNotify(action, data, messaging, retryConfig) {
6+
/**
7+
* @param {typeof ContentFeature} ContentFeatureClass
8+
*/
9+
export function ActionExecutorMixin(ContentFeatureClass) {
10+
return class Mixin extends ContentFeatureClass {
11+
/**
12+
* @param {any} action
13+
* @param {Record<string, any>} data
14+
* @param {any} retryConfig
15+
*/
16+
async processActionAndNotify(action, data, retryConfig) {
917
try {
1018
if (!action) {
11-
return messaging.notify('actionError', { error: 'No action found.' });
19+
return this.messaging.notify('actionError', { error: 'No action found.' });
1220
}
1321

1422
const { results, exceptions } = await this.exec(action, data, retryConfig);
@@ -20,7 +28,7 @@ export function ActionExecutorMixin(BaseClass) {
2028

2129
// if there are no secondary actions, or just no errors in general, just report the parent action
2230
if (results.length === 1 || errors.length === 0) {
23-
return messaging.notify('actionCompleted', { result: parent });
31+
return this.messaging.notify('actionCompleted', { result: parent });
2432
}
2533

2634
// here we must have secondary actions that failed.
@@ -32,13 +40,13 @@ export function ActionExecutorMixin(BaseClass) {
3240
message: 'Secondary actions failed: ' + joinedErrors,
3341
});
3442

35-
return messaging.notify('actionCompleted', { result: response });
43+
return this.messaging.notify('actionCompleted', { result: response });
3644
} else {
37-
return messaging.notify('actionError', { error: 'No response found, exceptions: ' + exceptions.join(', ') });
45+
return this.messaging.notify('actionError', { error: 'No response found, exceptions: ' + exceptions.join(', ') });
3846
}
3947
} catch (e) {
4048
console.log('unhandled exception: ', e);
41-
return messaging.notify('actionError', { error: e.toString() });
49+
return this.messaging.notify('actionError', { error: e.toString() });
4250
}
4351
}
4452

@@ -80,7 +88,7 @@ export default class BrokerProtection extends ActionExecutorMixin(ContentFeature
8088
init() {
8189
this.messaging.subscribe('onActionReceived', async (/** @type {any} */ params) => {
8290
const { action, data } = params.state;
83-
await this.processActionAndNotify(action, data, this.messaging, this.retryConfigFor(action));
91+
return await this.processActionAndNotify(action, data, this.retryConfigFor(action));
8492
});
8593
}
8694

0 commit comments

Comments
 (0)