mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
* Create ForegroundSyncService For Delegating `fullSync` calls to the background * Relax `isExternalMessage` to Allow For Typed Payload * Null Coalesce The `startListening` Method * Filter To Only External Messages
24 lines
712 B
TypeScript
24 lines
712 B
TypeScript
import { MonoTypeOperatorFunction, map } from "rxjs";
|
|
|
|
import { Message, CommandDefinition } from "./types";
|
|
|
|
export const getCommand = (commandDefinition: CommandDefinition<object> | string) => {
|
|
if (typeof commandDefinition === "string") {
|
|
return commandDefinition;
|
|
} else {
|
|
return commandDefinition.command;
|
|
}
|
|
};
|
|
|
|
export const EXTERNAL_SOURCE_TAG = Symbol("externalSource");
|
|
|
|
export const isExternalMessage = (message: Record<PropertyKey, unknown>) => {
|
|
return message?.[EXTERNAL_SOURCE_TAG] === true;
|
|
};
|
|
|
|
export const tagAsExternal: MonoTypeOperatorFunction<Message<object>> = map(
|
|
(message: Message<object>) => {
|
|
return Object.assign(message, { [EXTERNAL_SOURCE_TAG]: true });
|
|
},
|
|
);
|