1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Remove Unnecessary async

This commit is contained in:
Justin Baur
2024-05-25 12:30:14 -04:00
parent aa3d42d3a5
commit df22809391

View File

@@ -1,4 +1,4 @@
import { Observable, Subscription, concatMap } from "rxjs"; import { Observable, Subscription, tap } from "rxjs";
import { Jsonify } from "type-fest"; import { Jsonify } from "type-fest";
import { Utils } from "@bitwarden/common/platform/misc/utils"; import { Utils } from "@bitwarden/common/platform/misc/utils";
@@ -40,8 +40,8 @@ export class BackgroundDerivedState<
const stateSubscription = this.state$ const stateSubscription = this.state$
.pipe( .pipe(
concatMap(async (state) => { tap((state) => {
await this.sendMessage( this.sendMessage(
{ {
action: "nextState", action: "nextState",
data: JSON.stringify(state), data: JSON.stringify(state),
@@ -67,7 +67,7 @@ export class BackgroundDerivedState<
const dataObj = JSON.parse(message.data) as Jsonify<TTo>; const dataObj = JSON.parse(message.data) as Jsonify<TTo>;
const data = this.deriveDefinition.deserialize(dataObj); const data = this.deriveDefinition.deserialize(dataObj);
await this.forceValue(data); await this.forceValue(data);
await this.sendResponse( this.sendResponse(
message, message,
{ {
action: "resolve", action: "resolve",
@@ -79,13 +79,11 @@ export class BackgroundDerivedState<
} }
} }
private async sendResponse( private sendResponse(
originalMessage: DerivedStateMessage, originalMessage: DerivedStateMessage,
response: Omit<DerivedStateMessage, "originator" | "id">, response: Omit<DerivedStateMessage, "originator" | "id">,
port: chrome.runtime.Port, port: chrome.runtime.Port,
) { ) {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.sendMessage( this.sendMessage(
{ {
...response, ...response,
@@ -95,10 +93,7 @@ export class BackgroundDerivedState<
); );
} }
private async sendMessage( private sendMessage(message: Omit<DerivedStateMessage, "originator">, port: chrome.runtime.Port) {
message: Omit<DerivedStateMessage, "originator">,
port: chrome.runtime.Port,
) {
port.postMessage({ port.postMessage({
...message, ...message,
originator: "background", originator: "background",