-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor in-context state to feature file #251
Conversation
Note: Password rules outdated
You can update the rules with the following command cd packages/password && npm run rules:update Once you've updated the rules, re-run the build from the root with |
59a7a80
to
027da2f
Compare
/** | ||
* Adding this here since only the extension currently supports this | ||
*/ | ||
inContextSignup = new InContextSignup(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can prevent the base InterfacePrototype
from growing in size for every feature we add by using composition like this and dependency injection so that the feature can call back to the device.
return TOOLTIP_TYPES.EmailSignup | ||
} | ||
|
||
return null | ||
} | ||
|
||
onIncontextSignup () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both of these methods are only relevant to this feature, so move these into it
async resetAutofillUI (callback) { | ||
this.removeAutofillUIFromPage() | ||
|
||
// Start the setup process again | ||
await this.refreshSettings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to refresh global settings - anything this 'feature' needs can be done in 'setupAutofill'
@@ -86,11 +65,6 @@ | |||
await this.postInit() | |||
} | |||
|
|||
removeAutofillUIFromPage () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to the base, since it's truly generic/reusable
/** | ||
* In the extension, we must resolve `inContextSignup` data as past of setup | ||
*/ | ||
await this.inContextSignup.init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if any features need 'startup' data, fetch it here inside 'setupAutofill'
@@ -47,6 +47,9 @@ class InterfacePrototype { | |||
/** @type {PasswordGenerator} */ | |||
passwordGenerator = new PasswordGenerator(); | |||
|
|||
/** @type {import("../InContextSignup.js").InContextSignup | null} */ | |||
inContextSignup = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
because not all devices support this yet, and TS helps by forcing us to check for null
permanentlyDismissed = false | ||
initiallyDismissed = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of adding to Settings
, why not just add some specific data here?
const incontextSignupDismissedAt = await this.device.deviceApi.request(new GetIncontextSignupDismissedAtCall(null)) | ||
this.permanentlyDismissed = Boolean(incontextSignupDismissedAt.permanentlyDismissedAt) | ||
this.initiallyDismissed = Boolean(incontextSignupDismissedAt.initiallyDismissedAt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the logic that was mixed between the extension transport and the Settings
, we can just make the call directly here and store the data ourselves without it expanding the scope of the Device or Settings
/** | ||
* @returns {Promise<boolean|null>} | ||
*/ | ||
async getIncontextSignupInitiallyDismissed () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This verbose pattern of fetching and verifying the data was for the global configuration, feature toggles and available input types since they affect ALL features one way or another.
I can see why you added these here, and we probably need to update the docs/guides to be clearer, but we shouldn't be expanding Settings
to include any new state from individual features. :)
@@ -55,7 +55,6 @@ async function extensionSpecificRuntimeConfiguration (deviceApi) { | |||
const contentScope = await getContentScopeConfig() | |||
const emailProtectionEnabled = isAutofillEnabledFromProcessedConfig(contentScope) | |||
const incontextSignupEnabled = isIncontextSignupEnabledFromProcessedConfig(contentScope) | |||
const incontextSignupDismissedAt = await deviceApi.send(new GetIncontextSignupDismissedAtCall(null)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, this appears to be user-state related and not actually relevant to 'global' settings, so it's moved into the feature file
I added a branch with integration tests, and this branch passed 🎉 (with the typo fix applied) -- #254 |
@alistairjcbrown feel free to just take over this PR/branch and rebase against the integration tests etc. Basically I'll leave you to apply both this + integration tests, just ping when ready and I can approve stuff :) |
fbd68c9
to
cc00fb2
Compare
Create a feature file for in-context state to be managed in, instead of using the settings setup which is intended for more global state.
cc00fb2
to
5196d5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Task/Issue URL: https://app.asana.com/0/1204250253793536/1204250253793536 Autofill Release: https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/6.4.1 ## Description Updates Autofill to version [6.4.1](https://github.com/duckduckgo/duckduckgo-autofill/releases/tag/6.4.1). ### Autofill 6.4.0 and 6.4.1 release notes ## What's Changed ### Tooling and Tests * Update integration tests for in-context signup by @alistairjcbrown in duckduckgo/duckduckgo-autofill#254 and duckduckgo/duckduckgo-autofill#255 * Update macOS browser repository ID in `asana-release.yml` by @ayoy in duckduckgo/duckduckgo-autofill#259 * Use node v18 and update actions to read `.nvmrc` file by @alistairjcbrown in duckduckgo/duckduckgo-autofill#269 * Bugfix: Update release script to add checkout path to node version file path by @alistairjcbrown in duckduckgo/duckduckgo-autofill#286 ### Source Code Updates * Refactor in-context state to feature file by @shakyShane in duckduckgo/duckduckgo-autofill#251 * Prevent duplicated schema types by using JSON schema throughout by @shakyShane in duckduckgo/duckduckgo-autofill#253 * Stop scanning pages with a large number of inputs by @alistairjcbrown in duckduckgo/duckduckgo-autofill#257 and duckduckgo/duckduckgo-autofill#262 * Ignore small email inputs by @alistairjcbrown in duckduckgo/duckduckgo-autofill#261 * Fix username not saved by @GioSensation in duckduckgo/duckduckgo-autofill#275 * Updates to in-context signup treatment by @alistairjcbrown and @GioSensation in duckduckgo/duckduckgo-autofill#284 **Full Changelog**: duckduckgo/duckduckgo-autofill@6.3.0...6.4.1 ## Steps to test This release has been tested during autofill development. For smoke test steps see [this task](https://app.asana.com/0/1198964220583541/1200583647142330/f). Co-authored-by: alistairjcbrown <alistairjcbrown@users.noreply.github.com>
Reviewer:
Asana:
Description
@alistairjcbrown This is my 100% my issue for not seeing this earlier, but I was debugging some things recently I noticed that the purpose of
Settings
has not been communicated correctly in the past, something I will address.For now, the short version is this: can we just create a feature-file for this work instead, which will allow you to hold your own internal state and not need to interact with settings as much (only for the true purpose, which was feature flags etc)
Please read through the comments and let me know if anything isn't clear, but the short version is this:
Settings
was designed as a cross-platform way to retrieve global settings/feature toggles etc, we shouldn't expand it's use to feature-related stateSettings
andextension.transport.js
I'm sure you'll be happy 😎Steps to test
Can you run this locally and see if it works? I just put it together as a POC (I've not changed any functionality of course) but it would be good to get this resolved before your feature is rolled out :)