Skip to content

Commit a55201e

Browse files
refactor back to hasArchiveFlagEnabled$ - more straight forward to the underlying logic
1 parent f3ef1ca commit a55201e

File tree

9 files changed

+13
-15
lines changed

9 files changed

+13
-15
lines changed

apps/desktop/src/vault/app/vault/item-footer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export class ItemFooterComponent implements OnInit, OnChanges {
225225
switchMap((id) =>
226226
combineLatest([
227227
this.cipherArchiveService.userCanArchive$(id),
228-
this.cipherArchiveService.showArchiveFeatures$(),
228+
this.cipherArchiveService.hasArchiveFlagEnabled$,
229229
]),
230230
),
231231
),

apps/web/src/app/vault/components/vault-items/vault-items.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("VaultItemsComponent", () => {
5858
{
5959
provide: CipherArchiveService,
6060
useValue: {
61-
showArchiveFeatures$: jest.fn().mockReturnValue(of(true)),
61+
hasArchiveFlagEnabled$: of(true),
6262
},
6363
},
6464
],

apps/web/src/app/vault/components/vault-items/vault-items.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class VaultItemsComponent<C extends CipherViewLike> {
146146
protected disableMenu$: Observable<boolean>;
147147
private restrictedTypes: RestrictedCipherType[] = [];
148148

149-
protected archiveFeatureEnabled$ = this.cipherArchiveService.showArchiveFeatures$();
149+
protected archiveFeatureEnabled$ = this.cipherArchiveService.hasArchiveFlagEnabled$;
150150

151151
constructor(
152152
protected cipherAuthorizationService: CipherAuthorizationService,

apps/web/src/app/vault/components/vault-items/vault-items.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default {
147147
{
148148
provide: CipherArchiveService,
149149
useValue: {
150-
showArchiveFeatures$: () => new BehaviorSubject(true).asObservable(),
150+
hasArchiveFlagEnabled$: of(true),
151151
},
152152
},
153153
],

apps/web/src/app/vault/individual-vault/vault-filter/components/vault-filter.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
258258
const [userId, showArchive] = await firstValueFrom(
259259
combineLatest([
260260
this.accountService.activeAccount$.pipe(getUserId),
261-
this.cipherArchiveService.showArchiveFeatures$(),
261+
this.cipherArchiveService.hasArchiveFlagEnabled$,
262262
]),
263263
);
264264

apps/web/src/app/vault/individual-vault/vault.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ export class VaultComponent<C extends CipherViewLike> implements OnInit, OnDestr
446446
allowedCiphers$,
447447
filter$,
448448
this.currentSearchText$,
449-
this.cipherArchiveService.showArchiveFeatures$(),
449+
this.cipherArchiveService.hasArchiveFlagEnabled$,
450450
]).pipe(
451451
filter(([ciphers, filter]) => ciphers != undefined && filter != undefined),
452452
concatMap(async ([ciphers, filter, searchText, showArchiveVault]) => {

libs/common/src/vault/abstractions/cipher-archive.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { CipherId, UserId } from "@bitwarden/common/types/guid";
44
import { CipherViewLike } from "@bitwarden/common/vault/utils/cipher-view-like-utils";
55

66
export abstract class CipherArchiveService {
7+
abstract hasArchiveFlagEnabled$: Observable<boolean>;
78
abstract archivedCiphers$(userId: UserId): Observable<CipherViewLike[]>;
89
abstract userCanArchive$(userId: UserId): Observable<boolean>;
9-
abstract showArchiveFeatures$(): Observable<boolean>;
1010
abstract userHasPremium$(userId: UserId): Observable<boolean>;
1111
abstract archiveWithServer(ids: CipherId | CipherId[], userId: UserId): Promise<void>;
1212
abstract unarchiveWithServer(ids: CipherId | CipherId[], userId: UserId): Promise<void>;

libs/common/src/vault/services/default-cipher-archive.service.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ describe("DefaultCipherArchiveService", () => {
109109
});
110110
});
111111

112-
describe("showArchiveFeatures$", () => {
112+
describe("hasArchiveFlagEnabled$", () => {
113113
it("returns true when feature flag is enabled", async () => {
114114
mockConfigService.getFeatureFlag$.mockReturnValue(of(true));
115115

116-
const result = await firstValueFrom(service.showArchiveFeatures$());
116+
const result = await firstValueFrom(service.hasArchiveFlagEnabled$);
117117

118118
expect(result).toBe(true);
119119
expect(mockConfigService.getFeatureFlag$).toHaveBeenCalledWith(
@@ -124,7 +124,7 @@ describe("DefaultCipherArchiveService", () => {
124124
it("returns false when feature flag is disabled", async () => {
125125
mockConfigService.getFeatureFlag$.mockReturnValue(of(false));
126126

127-
const result = await firstValueFrom(service.showArchiveFeatures$());
127+
const result = await firstValueFrom(service.hasArchiveFlagEnabled$);
128128

129129
expect(result).toBe(false);
130130
});

libs/common/src/vault/services/default-cipher-archive.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ export class DefaultCipherArchiveService implements CipherArchiveService {
5858
}
5959

6060
/** Returns true when the archive features should be shown. */
61-
showArchiveFeatures$(): Observable<boolean> {
62-
return this.configService
63-
.getFeatureFlag$(FeatureFlag.PM19148_InnovationArchive)
64-
.pipe(shareReplay({ refCount: true, bufferSize: 1 }));
65-
}
61+
hasArchiveFlagEnabled$: Observable<boolean> = this.configService
62+
.getFeatureFlag$(FeatureFlag.PM19148_InnovationArchive)
63+
.pipe(shareReplay({ refCount: true, bufferSize: 1 }));
6664

6765
/** Returns true when the user has premium from any means. */
6866
userHasPremium$(userId: UserId): Observable<boolean> {

0 commit comments

Comments
 (0)