refactor: migrate NotificationsMenu to TypeScript

This commit is contained in:
LuanRT
2022-07-29 01:00:56 -03:00
parent c16d632b31
commit 7ba09a66d8
5 changed files with 71 additions and 42 deletions

View File

@@ -212,15 +212,30 @@ class NavigationEndpoint extends YTNode {
}
/**
* Calls the endpoint. (This is an experiment and may replace {@link call} in the future.).
* Call endpoint. (This is an experiment and may replace {@link call} in the future.).
*/
async callTest(actions: Actions, args = { parse: true, params: {} }) {
async callTest(actions: Actions, args: {
parse: false;
params?: { [key: string]: any; }
}): Promise<ActionsResponse>;
async callTest(actions: Actions, args?: {
parse: true;
params?: { [key: string]: any; }
}): Promise<ParsedResponse>;
async callTest(actions: Actions, args: {
parse: boolean;
params: { [key: string]: any; }
}): Promise<ParsedResponse | ActionsResponse>;
async callTest(actions: Actions, args?: {
parse?: boolean;
params?: { [key: string]: any; }
}): Promise<ParsedResponse | ActionsResponse> {
if (!actions)
throw new Error('An active caller must be provided');
if (!this.metadata.api_url)
throw new Error('Expected an api_url, but none was found, this is a bug.');
const response = await actions.execute(this.metadata.api_url, { ...this.payload, ...args.params, parse: args.parse });
const response = await actions.execute(this.metadata.api_url, { ...this.payload, ...(args?.params || {}), parse: args ? args.parse : true });
return response;
}