Skip to content

Commit

Permalink
Match event detail (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Oct 17, 2024
1 parent 657d404 commit 88df4bc
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/dh/dhe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,6 @@ export async function hasInteractivePermission(
return isSuperUser || isInteractive;
}

/**
* Find the `QueryInfo` matching the given serial.
* @param dheClient DHE client to search.
* @param matchSerial Serial to match.
* @returns The matching `QueryInfo` or `undefined` if not found.
*/
export function findQueryConfigForSerial(
dheClient: EnterpriseClient,
matchSerial: string
): QueryInfo | undefined {
return dheClient
.getKnownConfigs()
.find(({ serial }) => serial === matchSerial);
}

/**
* Create a query of type `InteractiveConsole`.
* @param tagId Unique tag id to include in the query name.
Expand Down Expand Up @@ -175,8 +160,6 @@ export async function createInteractiveConsoleQuery(
draftQuery.updateSchedule();
}

console.log('[TESTING] schedule:', draftQuery.scheduler);

// type assertion gives us stronger type safety than the Promise<string>
// return type defined by the JS API types.
return dheClient.createQuery(draftQuery) as Promise<QuerySerial>;
Expand Down Expand Up @@ -214,9 +197,11 @@ export async function getWorkerInfoFromQuery(
const queryInfo = await new Promise<QueryInfo>(resolve => {
dheClient.addEventListener(
dhe.Client.EVENT_CONFIG_UPDATED,
(event: CustomEvent<QueryInfo>) => {
// const queryInfo = findQueryConfigForSerial(dheClient, querySerial);
if (queryInfo?.designated?.grpcUrl != null) {
({ detail: queryInfo }: CustomEvent<QueryInfo>) => {
if (
queryInfo.serial === querySerial &&
queryInfo.designated?.grpcUrl != null
) {
resolve(queryInfo);
}
}
Expand Down

0 comments on commit 88df4bc

Please sign in to comment.