Skip to content
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

Fix "show toast on new install" logic #4024

Merged
merged 2 commits into from
Jun 2, 2023
Merged

Fix "show toast on new install" logic #4024

merged 2 commits into from
Jun 2, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Jun 1, 2023

  • uses global state to check if a extension is being used for the first time

Demo

I tested locally and on codespaces. Note that global extension state stays even after you uninstall the extension.

local.mov

Resolves #3994 (comment)

@julieg18 julieg18 added the bug Something isn't working label Jun 1, 2023
@julieg18 julieg18 self-assigned this Jun 1, 2023
@@ -1,4 +1,4 @@
import { commands, env, ExtensionContext, ViewColumn } from 'vscode'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #3994 (comment), we shouldn't be using env in the scenario.

@@ -1,9 +1,15 @@
import { commands, Memento } from 'vscode'

export const resetPersistedState = async (workspaceState: Memento) => {
export const resetPersistedState = async (
Copy link
Contributor Author

@julieg18 julieg18 Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated our resetPersistedState to include the global state since it is a form of persisted state. Helps with testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Are we sure that all of the keys under here only relate to our extension?


// old users won't have the installedKey even if it's not a new install
const workspaceKeys = workspaceState.keys()
return showSetupToast(workspaceKeys.length === 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We check for workspaceKeys length since an old user will have these set. I suppose we could take off this extra check in about a month like we've done in the past.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Same question. Are you sure everything in the workspaceState only relates to our extension?

Copy link
Contributor Author

@julieg18 julieg18 Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that workspaceState and globalState both relate only to our extension since looking at the docs for ExtensionContext:

     * An extension context is a collection of utilities private to an
     * extension.

Plus I was console logging both states before I touched anything. globalState was completely empty and workspaceState only had keys set by our extension.

@julieg18 julieg18 marked this pull request as ready for review June 1, 2023 19:30
@julieg18 julieg18 requested review from mattseddon and sroy3 as code owners June 1, 2023 19:30
@julieg18 julieg18 enabled auto-merge (squash) June 2, 2023 12:38
@codeclimate
Copy link

codeclimate bot commented Jun 2, 2023

Code Climate has analyzed commit 47418c7 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 90.0% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.2% (0.0% change).

View more on Code Climate.

@julieg18 julieg18 merged commit c46f725 into main Jun 2, 2023
@julieg18 julieg18 deleted the fix-on-install-logic branch June 2, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants