mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[PM-24105] Remove usage of getUserKey on keyService (#16626)
• prefer undefined over null • obtain required UserId once per method, before branching • guards moved to beginning of methods * lift UserId retrieval to occur once during import * remove redundant userId retrieval
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { inject, Injectable } from "@angular/core";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { Send } from "@bitwarden/common/tools/send/models/domain/send";
|
||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
||||
@@ -12,11 +15,13 @@ import { SendFormService } from "../abstractions/send-form.service";
|
||||
|
||||
@Injectable()
|
||||
export class DefaultSendFormService implements SendFormService {
|
||||
private accountService = inject(AccountService);
|
||||
private sendApiService: SendApiService = inject(SendApiService);
|
||||
private sendService = inject(SendService);
|
||||
|
||||
async decryptSend(send: Send): Promise<SendView> {
|
||||
return await send.decrypt();
|
||||
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
|
||||
return await send.decrypt(userId);
|
||||
}
|
||||
|
||||
async saveSend(send: SendView, file: File | ArrayBuffer, config: SendFormConfig) {
|
||||
|
||||
Reference in New Issue
Block a user