mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 05:30:01 +00:00
typecheck
This commit is contained in:
@@ -29,6 +29,8 @@ export class AchievementCard {
|
||||
|
||||
protected cardClass: string;
|
||||
constructor() {
|
||||
this.cardClass = "";
|
||||
|
||||
effect(() => {
|
||||
const earned = this.earned();
|
||||
const progress = this.progress();
|
||||
|
||||
@@ -30,6 +30,8 @@ export class AchievementItem {
|
||||
|
||||
protected cardClass: string;
|
||||
constructor() {
|
||||
this.cardClass = "";
|
||||
|
||||
effect(() => {
|
||||
const earned = this.earned();
|
||||
const progress = this.progress();
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Icon, ToastService } from "@bitwarden/components";
|
||||
|
||||
import { AchievementNotifierService as AchievementNotifierServiceAbstraction } from "./achievement-notifier.abstraction";
|
||||
import { AchievementIcon } from "./icons/achievement.icon";
|
||||
import { iconMap } from "./icons/iconMap";
|
||||
import { iconMap } from "./icons/icon-map";
|
||||
|
||||
export class AchievementNotifierService implements AchievementNotifierServiceAbstraction {
|
||||
constructor(
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
|
||||
import { AchievementItem } from "./achievement-item.component";
|
||||
import { AchievementIcon } from "./icons/achievement.icon";
|
||||
import { iconMap } from "./icons/iconMap";
|
||||
import { iconMap } from "./icons/icon-map";
|
||||
|
||||
@Component({
|
||||
selector: "achievements-list",
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "../types";
|
||||
|
||||
export class AttachmentAddedValidator implements AchievementValidator {
|
||||
base: AchievementValidator;
|
||||
base: Pick<AchievementValidator, "active">;
|
||||
get achievement() {
|
||||
return "item-attached" as AchievementId;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export class AttachmentAddedValidator implements AchievementValidator {
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.base.active = "until-earned";
|
||||
this.base = { active: "until-earned" };
|
||||
}
|
||||
|
||||
trigger(item: UserActionEvent) {
|
||||
|
||||
@@ -92,9 +92,14 @@ export class ItemCreatedCountConfig implements Achievement {
|
||||
get hidden() {
|
||||
return this.base.hidden;
|
||||
}
|
||||
cipherType: CipherType = null;
|
||||
cipherType: CipherType | null = null;
|
||||
threshold: number;
|
||||
private constructor(key: string, name: string, threshold: number, cipherType: CipherType = null) {
|
||||
private constructor(
|
||||
key: string,
|
||||
name: string,
|
||||
threshold: number,
|
||||
cipherType: CipherType | null = null,
|
||||
) {
|
||||
this.cipherType = cipherType;
|
||||
this.threshold = threshold;
|
||||
this.base = {
|
||||
|
||||
@@ -16,7 +16,8 @@ export class SendItemCreatedCountConfig implements Achievement {
|
||||
new SendItemCreatedCountConfig("send-item-created-100", "100 send items created", 100),
|
||||
];
|
||||
|
||||
base: Achievement;
|
||||
base: Omit<Achievement, "validator" | "hidden">;
|
||||
|
||||
get achievement() {
|
||||
return this.base.achievement;
|
||||
}
|
||||
@@ -39,12 +40,14 @@ export class SendItemCreatedCountConfig implements Achievement {
|
||||
threshold: number;
|
||||
private constructor(key: string, name: string, threshold: number) {
|
||||
this.threshold = threshold;
|
||||
this.base.achievement = key as AchievementId;
|
||||
this.base.name = name;
|
||||
this.base.active = {
|
||||
metric: "send-item-quantity" as MetricId,
|
||||
low: threshold - 1,
|
||||
high: threshold,
|
||||
this.base = {
|
||||
achievement: key as AchievementId,
|
||||
name: name,
|
||||
active: {
|
||||
metric: "send-item-quantity" as MetricId,
|
||||
low: threshold - 1,
|
||||
high: threshold,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "../types";
|
||||
|
||||
export class ItemCollectionMoveValidator implements AchievementValidator {
|
||||
base: AchievementValidator;
|
||||
base: Pick<AchievementValidator, "active">;
|
||||
get achievement() {
|
||||
return "item-collection-move" as AchievementId;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export class ItemCollectionMoveValidator implements AchievementValidator {
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.base.active = "until-earned";
|
||||
this.base = { active: "until-earned" };
|
||||
}
|
||||
|
||||
trigger(item: UserActionEvent) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "../types";
|
||||
|
||||
export class ItemFolderAddedValidator implements AchievementValidator {
|
||||
base: AchievementValidator;
|
||||
base: Pick<AchievementValidator, "active">;
|
||||
get achievement() {
|
||||
return "item-folder-added" as AchievementId;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export class ItemFolderAddedValidator implements AchievementValidator {
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.base.active = "until-earned";
|
||||
this.base = { active: "until-earned" };
|
||||
}
|
||||
|
||||
trigger(item: UserActionEvent) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "../types";
|
||||
|
||||
export class ItemRemovedValidator implements AchievementValidator {
|
||||
base: AchievementValidator;
|
||||
base: Pick<AchievementValidator, "active">;
|
||||
get achievement() {
|
||||
return "item-removed" as AchievementId;
|
||||
}
|
||||
@@ -29,9 +29,11 @@ export class ItemRemovedValidator implements AchievementValidator {
|
||||
}
|
||||
private metric = "item-removed-quantity" as MetricId;
|
||||
constructor() {
|
||||
this.base.active = {
|
||||
metric: this.metric,
|
||||
high: 1,
|
||||
this.base = {
|
||||
active: {
|
||||
metric: this.metric,
|
||||
high: 1,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "../types";
|
||||
|
||||
export class ItemUriAddedValidator implements AchievementValidator {
|
||||
base: AchievementValidator;
|
||||
base: Pick<AchievementValidator, "active">;
|
||||
get achievement() {
|
||||
return "item-uri-added" as AchievementId;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export class ItemUriAddedValidator implements AchievementValidator {
|
||||
|
||||
constructor() {
|
||||
// If edit and the uri count is present the achievement is rewarded
|
||||
this.base.active = "until-earned";
|
||||
this.base = { active: "until-earned" };
|
||||
}
|
||||
|
||||
trigger(item: UserActionEvent) {
|
||||
|
||||
@@ -26,7 +26,6 @@ export class SendItemCreatedCountValidator implements AchievementValidator {
|
||||
return configs.map((config) => new SendItemCreatedCountValidator(config));
|
||||
}
|
||||
|
||||
base: AchievementValidator;
|
||||
get achievement() {
|
||||
return this.config.achievement;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ export class VaultItemCreatedCountValidator implements AchievementValidator {
|
||||
return configs.map((config) => new VaultItemCreatedCountValidator(config));
|
||||
}
|
||||
|
||||
base: AchievementValidator;
|
||||
get achievement() {
|
||||
return this.config.achievement;
|
||||
}
|
||||
@@ -81,7 +80,7 @@ export class VaultItemCreatedCountValidator implements AchievementValidator {
|
||||
}
|
||||
|
||||
const lowerConfigType = CipherType[this.config.cipherType].toLowerCase();
|
||||
const lowerItemType = item.labels?.["vault-item-type"].toString().toLowerCase();
|
||||
const lowerItemType = item.labels?.["vault-item-type"]?.toString()?.toLowerCase();
|
||||
return lowerItemType === lowerConfigType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PolicyService } from "../admin-console/abstractions/policy/policy.servi
|
||||
|
||||
import { ExtensionService } from "./extension/extension.service";
|
||||
import { LogProvider } from "./log";
|
||||
import { UserEventCollector } from "./log/user-event-monitor";
|
||||
import { UserEventMonitor } from "./log/user-event-monitor";
|
||||
|
||||
/** Provides access to commonly-used cross-cutting services. */
|
||||
export type SystemServiceProvider = {
|
||||
@@ -15,5 +15,5 @@ export type SystemServiceProvider = {
|
||||
/** Event monitoring and diagnostic interfaces */
|
||||
readonly log: LogProvider;
|
||||
|
||||
readonly event: UserEventCollector;
|
||||
readonly event: UserEventMonitor;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user