Skip to content

Commit

Permalink
frontend/transport: fix onAndroidCallResponse type
Browse files Browse the repository at this point in the history
It returns `any` (whatever JSON the backend handler returns), not
`string`, just like the functions that call this: `apiGet()` and
`apiPost()`.
  • Loading branch information
benma committed Dec 11, 2023
1 parent 01700c4 commit 520fbc2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontends/web/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export declare global {
android?: {
call: (queryID: number, query: string) => void;
}
onAndroidCallResponse?: (queryID: number, response: string) => void;
onAndroidCallResponse?: (queryID: number, response: any) => void;
onAndroidPushNotification?: (msg: TPayload) => void;
}
}
4 changes: 2 additions & 2 deletions frontends/web/src/utils/transport-android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ let queryID: number = 0;
const queryPromises: TQueryPromiseMap = {};
const currentListeners: TMsgCallback[] = [];

export function androidCall(query: string) {
export function androidCall(query: string): Promise<any> {
return new Promise((resolve, reject) => {
if (runningInAndroid()) {
if (typeof window.onAndroidCallResponse === 'undefined') {
window.onAndroidCallResponse = (
queryID: number,
response: string,
response: any,
) => {
queryPromises[queryID].resolve(response);
delete queryPromises[queryID];
Expand Down
2 changes: 1 addition & 1 deletion frontends/web/src/utils/transport-qt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function initTransport() {
return webChannel;
}

export function call(query: string) {
export function call(query: string): Promise<any> {
return new Promise((resolve, reject) => {
initTransport().then((channel: any) => {
queryID++;
Expand Down

0 comments on commit 520fbc2

Please sign in to comment.