Skip to content

Commit

Permalink
refactor set context from repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Jan 25, 2023
1 parent 03ac397 commit 86029d3
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions extension/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ export class Context extends Disposable {
(experiments: Experiments) => experiments.hasRunningExperiment()
)

const hasRunningQueuedExperiment = this.repositoriesHaveRequirement(
repositories,
(experiments: Experiments) => experiments.hasRunningQueuedExperiment()
const hasRunningQueuedExperiment = repositories.some(experiments =>
experiments.hasRunningQueuedExperiment()
)

void setContextValue(
Expand All @@ -84,20 +83,9 @@ export class Context extends Disposable {
repositories: Experiments[],
hasRequirement: (experiments: Experiments) => boolean
) {
const value = this.repositoriesHaveRequirement(repositories, hasRequirement)

void setContextValue(contextKey, value)
}

private repositoriesHaveRequirement(
repositories: Experiments[],
hasRequirement: (experiments: Experiments) => boolean
) {
for (const experiments of repositories) {
if (hasRequirement(experiments)) {
return true
}
}
return false
void setContextValue(
contextKey,
repositories.some(experiments => hasRequirement(experiments))
)
}
}

0 comments on commit 86029d3

Please sign in to comment.