-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move extension refresh swap function to libs so other clients can use…
… it (#10640) * Move extension refresh swap function to libs so other clients can use it * Update extensionRefreshSwap docs
- Loading branch information
1 parent
19ef6ba
commit 924d0b7
Showing
3 changed files
with
36 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Type, inject } from "@angular/core"; | ||
import { Route, Routes } from "@angular/router"; | ||
|
||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; | ||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; | ||
|
||
import { componentRouteSwap } from "./component-route-swap"; | ||
|
||
/** | ||
* Helper function to swap between two components based on the ExtensionRefresh feature flag. | ||
* @param defaultComponent - The current non-refreshed component to render. | ||
* @param refreshedComponent - The new refreshed component to render. | ||
* @param options - The shared route options to apply to the default component, and to the alt component if altOptions is not provided. | ||
* @param altOptions - The alt route options to apply to the alt component. | ||
*/ | ||
export function extensionRefreshSwap( | ||
defaultComponent: Type<any>, | ||
refreshedComponent: Type<any>, | ||
options: Route, | ||
altOptions?: Route, | ||
): Routes { | ||
return componentRouteSwap( | ||
defaultComponent, | ||
refreshedComponent, | ||
async () => { | ||
const configService = inject(ConfigService); | ||
return configService.getFeatureFlag(FeatureFlag.ExtensionRefresh); | ||
}, | ||
options, | ||
altOptions, | ||
); | ||
} |