Skip to content

Commit a5ab6c3

Browse files
refactor: simplify isFirstUse for Q
Avoid any invalid logic involved with hasExistingConnections() Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 0fa1b5b commit a5ab6c3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/core/src/auth/utils.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -688,17 +688,24 @@ export class ExtensionUse {
688688
return this.isFirstUseCurrentSession
689689
}
690690

691-
this.isFirstUseCurrentSession = globals.globalState.get('isExtensionFirstUse')
692-
if (this.isFirstUseCurrentSession === undefined) {
691+
// This is for sure not their first use
692+
const isFirstUse = globals.globalState.tryGet('isExtensionFirstUse', Boolean)
693+
if (isFirstUse === false) {
694+
this.isFirstUseCurrentSession = isFirstUse
695+
return this.isFirstUseCurrentSession
696+
}
697+
698+
if (isAmazonQ()) {
699+
this.isFirstUseCurrentSession = true
700+
} else {
693701
// The variable in the store is not defined yet, fallback to checking if they have existing connections.
694702
this.isFirstUseCurrentSession = !hasExistingConnections()
695-
696-
getLogger().debug(
697-
`isFirstUse: State not found, marking user as '${
698-
this.isFirstUseCurrentSession ? '' : 'NOT '
699-
}first use' since they 'did ${this.isFirstUseCurrentSession ? 'NOT ' : ''}have existing connections'.`
700-
)
701703
}
704+
getLogger().debug(
705+
`isFirstUse: State not found, marking user as '${
706+
this.isFirstUseCurrentSession ? '' : 'NOT '
707+
}first use' since they 'did ${this.isFirstUseCurrentSession ? 'NOT ' : ''}have existing connections'.`
708+
)
702709

703710
// Update state, so next time it is not first use
704711
this.updateMemento('isExtensionFirstUse', false)

0 commit comments

Comments
 (0)