Skip to content

Commit

Permalink
fix: bail early on unsupported urls
Browse files Browse the repository at this point in the history
  • Loading branch information
dbajpeyi committed Oct 11, 2024
1 parent b1c9510 commit 417b083
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
25 changes: 18 additions & 7 deletions build/integration/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -22068,8 +22068,14 @@
#settingsButtonSettings = {}
#signInButtonSettings = {}

SUPPORTED_PATHS = {
SIGNIN: '/intro',
EXPORT: '/options',
SETTINGS: '/'
}

async getElementAndStyleFromPath (path) {
if (path === '/') {
if (path === this.SUPPORTED_PATHS.SETTINGS) {
return {
style: {
scale: 1,
Expand All @@ -22078,7 +22084,7 @@
element: await this.findSettingsElement(),
shouldTap: this.#settingsButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/options') {
} else if (path === this.SUPPORTED_PATHS.EXPORT) {
return {
style: {
scale: 1.01,
Expand All @@ -22087,7 +22093,7 @@
element: await this.findExportElement(),
shouldTap: this.#exportButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/intro') {
} else if (path === this.SUPPORTED_PATHS.SIGNIN) {
return {
style: {
scale: 1.5,
Expand Down Expand Up @@ -22142,10 +22148,15 @@
}

async handleElementForPath (path) {
const animateElement = this.animateElement.bind(this);
const { element, style, shouldTap } = await this.getElementAndStyleFromPath(path) ?? {};
if (element != null) {
shouldTap ? this.autotapElement(element) : animateElement(element, style);
// FIXME: This is a workaround, we need to check if the path is supported, otherwise
// for some reason google doesn't wait to proceed with the signin step.
// Not too sure why this is happening, there are no errors on the console.

if (Object.values(this.SUPPORTED_PATHS).includes(path)) {
const { element, style, shouldTap } = await this.getElementAndStyleFromPath(path) ?? {};
if (element != null) {
shouldTap ? this.autotapElement(element) : this.animateElement(element, style);
}
}
}

Expand Down
25 changes: 18 additions & 7 deletions src/features/password-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ export default class PasswordImport extends ContentFeature {
#settingsButtonSettings = {}
#signInButtonSettings = {}

SUPPORTED_PATHS = {
SIGNIN: '/intro',
EXPORT: '/options',
SETTINGS: '/'
}

async getElementAndStyleFromPath (path) {
if (path === '/') {
if (path === this.SUPPORTED_PATHS.SETTINGS) {
return {
style: {
scale: 1,
Expand All @@ -16,7 +22,7 @@ export default class PasswordImport extends ContentFeature {
element: await this.findSettingsElement(),
shouldTap: this.#settingsButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/options') {
} else if (path === this.SUPPORTED_PATHS.EXPORT) {
return {
style: {
scale: 1.01,
Expand All @@ -25,7 +31,7 @@ export default class PasswordImport extends ContentFeature {
element: await this.findExportElement(),
shouldTap: this.#exportButtonSettings.autotap?.enabled ?? false
}
} else if (path === '/intro') {
} else if (path === this.SUPPORTED_PATHS.SIGNIN) {
return {
style: {
scale: 1.5,
Expand Down Expand Up @@ -80,10 +86,15 @@ export default class PasswordImport extends ContentFeature {
}

async handleElementForPath (path) {
const animateElement = this.animateElement.bind(this)
const { element, style, shouldTap } = await this.getElementAndStyleFromPath(path) ?? {}
if (element != null) {
shouldTap ? this.autotapElement(element) : animateElement(element, style)
// FIXME: This is a workaround, we need to check if the path is supported, otherwise
// for some reason google doesn't wait to proceed with the signin step.
// Not too sure why this is happening, there are no errors on the console.

if (Object.values(this.SUPPORTED_PATHS).includes(path)) {
const { element, style, shouldTap } = await this.getElementAndStyleFromPath(path) ?? {}
if (element != null) {
shouldTap ? this.autotapElement(element) : this.animateElement(element, style)
}
}
}

Expand Down

0 comments on commit 417b083

Please sign in to comment.