Skip to content

Commit 146817c

Browse files
Merge pull request #116 from Accedia/fix-deploy
Fix deploy
2 parents 46b1b65 + 092fd18 commit 146817c

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

electron-app/src/utils/mitchell_importer.ts

+43-23
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ export class Mitchell_Importer extends Importer {
4545
/** Delay between keystrokes when typing a word (e.g. calling keyboard.type(), time between each letter keypress). */
4646
keyboard['nativeAdapter'].keyboard.setKeyboardDelay(inputSpeed * 50);
4747
/** Path with the assets, where we put images for "Manual Line" button image-recognition */
48+
// screen.config.resourceDirectory = isLookingForCommitButton
49+
// ? this.getMitchellPathForCommitButton()
50+
// : isLookingForCommitBtnInModal
51+
// ? this.getMitchellPathForCommitButtonInModal()
52+
// : this.getMitchellPathForAssets();
53+
4854
screen.config.resourceDirectory = isLookingForCommitButton
4955
? this.getMitchellPathForCommitButton()
50-
: isLookingForCommitBtnInModal
51-
? this.getMitchellPathForCommitButtonInModal()
5256
: this.getMitchellPathForAssets();
53-
5457
// ! Left only for debug purposes
5558
// ? Uncomment if needed, do not deploy to prod
5659
if (isLookingForCommitButton) {
@@ -111,7 +114,8 @@ export class Mitchell_Importer extends Importer {
111114
);
112115

113116
if (commitButtonCoordinates) {
114-
await this.commitMitchellData(commitButtonCoordinates, electronWindow);
117+
await this.commitMitchellData(commitButtonCoordinates);
118+
// await this.commitMitchellData(commitButtonCoordinates, electronWindow);
115119
} else {
116120
log.error("Can't find the Commit Button.");
117121
}
@@ -158,9 +162,13 @@ export class Mitchell_Importer extends Importer {
158162
const buttonCoordinates =
159163
typeButton === MitchellButtons.manualLineButton
160164
? await this.checkForButtonCoordinates(MitchellButtons.manualLineButton, electronWindow)
161-
: typeButton === MitchellButtons.commitButton
162-
? await this.checkForButtonCoordinates(MitchellButtons.commitButton, electronWindow)
163-
: await this.checkForButtonCoordinates(MitchellButtons.commitButtonInModal, electronWindow);
165+
: await this.checkForButtonCoordinates(MitchellButtons.commitButton, electronWindow);
166+
// const buttonCoordinates =
167+
// typeButton === MitchellButtons.manualLineButton
168+
// ? await this.checkForButtonCoordinates(MitchellButtons.manualLineButton, electronWindow)
169+
// : typeButton === MitchellButtons.commitButton
170+
// ? await this.checkForButtonCoordinates(MitchellButtons.commitButton, electronWindow)
171+
// : await this.checkForButtonCoordinates(MitchellButtons.commitButtonInModal, electronWindow);
164172
if (buttonCoordinates) {
165173
const messageToSendToReact =
166174
typeButton === MitchellButtons.manualLineButton
@@ -182,9 +190,13 @@ export class Mitchell_Importer extends Importer {
182190
const images =
183191
typeButton === MitchellButtons.manualLineButton
184192
? fs.readdirSync(this.getMitchellPathForAssets())
185-
: typeButton === MitchellButtons.commitButton
186-
? fs.readdirSync(this.getMitchellPathForCommitButton())
187-
: fs.readdirSync(this.getMitchellPathForCommitButtonInModal());
193+
: fs.readdirSync(this.getMitchellPathForCommitButton());
194+
// const images =
195+
// typeButton === MitchellButtons.manualLineButton
196+
// ? fs.readdirSync(this.getMitchellPathForAssets())
197+
// : typeButton === MitchellButtons.commitButton
198+
// ? fs.readdirSync(this.getMitchellPathForCommitButton())
199+
// : fs.readdirSync(this.getMitchellPathForCommitButtonInModal());
188200
const result: ImageSearchResult = {
189201
coordinates: null,
190202
errors: [],
@@ -413,24 +425,32 @@ export class Mitchell_Importer extends Importer {
413425
await snooze(4000); // wait until modal is closed
414426
};
415427

416-
private commitMitchellData = async (commitButtonCoordinates: Point, electronWindow: BrowserWindow) => {
428+
private commitMitchellData = async (commitButtonCoordinates: Point) => {
417429
await mouse.setPosition(commitButtonCoordinates);
418430
await mouse.leftClick();
419431
this.progressUpdater.update();
420-
const inputSpeed = getInputSpeed();
421-
const inputSpeedSeconds = getInputSpeedInSeconds(inputSpeed);
432+
// logic for searching by image
433+
// const inputSpeed = getInputSpeed();
434+
// const inputSpeedSeconds = getInputSpeedInSeconds(inputSpeed);
422435

423-
this.setMitchellConfig(inputSpeedSeconds, false, true);
436+
// this.setMitchellConfig(inputSpeedSeconds, false, true);
424437
await snooze(6000);
425-
const coordinatesOfButtonInModal = await this.getButtonCoordinates(
426-
electronWindow,
427-
MitchellButtons.commitButtonInModal
428-
);
429-
if (coordinatesOfButtonInModal) {
430-
await mouse.setPosition(coordinatesOfButtonInModal);
431-
await mouse.leftClick();
432-
this.progressUpdater.setPercentage(100);
433-
}
438+
await this.pressTabButton(3);
439+
this.progressUpdater.update();
440+
await this.pressTabButton(3);
441+
this.progressUpdater.update();
442+
await keyboard.pressKey(Key.Enter);
443+
await keyboard.releaseKey(Key.Enter);
444+
this.progressUpdater.setPercentage(100);
445+
// const coordinatesOfButtonInModal = await this.getButtonCoordinates(
446+
// electronWindow,
447+
// MitchellButtons.commitButtonInModal
448+
// );
449+
// if (coordinatesOfButtonInModal) {
450+
// await mouse.setPosition(coordinatesOfButtonInModal);
451+
// await mouse.leftClick();
452+
// this.progressUpdater.setPercentage(100);
453+
// }
434454
};
435455
}
436456

0 commit comments

Comments
 (0)