mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
Refactor environment service to emit a single observable. This required significant changes to how the environment service behaves and tackles much of the tech debt planned for it.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { firstValueFrom } from "rxjs";
|
|
|
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
|
import { SendService } from "@bitwarden/common/tools/send/services//send.service.abstraction";
|
|
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
|
|
|
import { Response } from "../../../models/response";
|
|
import { SendResponse } from "../models/send.response";
|
|
|
|
export class SendRemovePasswordCommand {
|
|
constructor(
|
|
private sendService: SendService,
|
|
private sendApiService: SendApiService,
|
|
private environmentService: EnvironmentService,
|
|
) {}
|
|
|
|
async run(id: string) {
|
|
try {
|
|
await this.sendApiService.removePassword(id);
|
|
|
|
const updatedSend = await this.sendService.get(id);
|
|
const decSend = await updatedSend.decrypt();
|
|
const env = await firstValueFrom(this.environmentService.environment$);
|
|
const webVaultUrl = env.getWebVaultUrl();
|
|
const res = new SendResponse(decSend, webVaultUrl);
|
|
return Response.success(res);
|
|
} catch (e) {
|
|
return Response.error(e);
|
|
}
|
|
}
|
|
}
|