diff --git a/src/common/front-end-routing/navigate-to-route-injection-token.ts b/src/common/front-end-routing/navigate-to-route-injection-token.ts index 29fb82867c..dfdc133fff 100644 --- a/src/common/front-end-routing/navigate-to-route-injection-token.ts +++ b/src/common/front-end-routing/navigate-to-route-injection-token.ts @@ -5,10 +5,6 @@ import { getInjectionToken } from "@ogre-tools/injectable"; import type { Route } from "./front-end-route-injection-token"; -type InferParametersFrom = TRoute extends Route - ? TParameters - : never; - type RequiredKeys = Exclude< { [K in keyof T]: T extends Record ? K : never; @@ -30,22 +26,21 @@ type ObjectContainsNoRequired = T extends ObjectContainingNoRequired // - Navigating to route without parameters, with parameters // - Navigating to route with required parameters, without parameters type Parameters = TParameters extends void - ? {} + ? { parameters?: never } : ObjectContainsNoRequired extends true - ? { parameters?: TParameters } - : { parameters: TParameters }; + ? { parameters?: TParameters } + : { parameters: TParameters }; -export type NavigateToRouteOptions = Parameters< - InferParametersFrom -> & { +export type NavigateToRouteOptions = Parameters & { query?: Record; fragment?: string; withoutAffectingBackButton?: boolean; }; -export type NavigateToRoute = >( +export type NavigateToRoute = , TParameter extends object>( route: TRoute, - options?: NavigateToRouteOptions) => void; + options?: NavigateToRouteOptions, +) => void; export const navigateToRouteInjectionToken = getInjectionToken( { id: "navigate-to-route-injection-token" }, diff --git a/src/main/navigate-to-route/navigate-to-route.injectable.ts b/src/main/navigate-to-route/navigate-to-route.injectable.ts index e097bf1569..b3dfffae28 100644 --- a/src/main/navigate-to-route/navigate-to-route.injectable.ts +++ b/src/main/navigate-to-route/navigate-to-route.injectable.ts @@ -13,15 +13,14 @@ const navigateToRouteInjectable = getInjectable({ instantiate: (di) => { const navigateToUrl = di.inject(navigateToUrlInjectionToken); - return async (route, options) => { + return (route, options) => { const url = buildURL(route.path, { - // TODO: enhance typing - params: options?.parameters as any, + params: options?.parameters, query: options?.query, fragment: options?.fragment, }); - await navigateToUrl(url, options); + navigateToUrl(url, options); }; }, diff --git a/src/test-utils/channel-fakes/override-messaging-from-main-to-window.ts b/src/test-utils/channel-fakes/override-messaging-from-main-to-window.ts index 171ac804f1..e69dbc4405 100644 --- a/src/test-utils/channel-fakes/override-messaging-from-main-to-window.ts +++ b/src/test-utils/channel-fakes/override-messaging-from-main-to-window.ts @@ -33,12 +33,6 @@ export const overrideMessagingFromMainToWindow = (mainDi: DiContainer) => { ); } - if (data.length > 1) { - throw new Error( - `Tried to send message to channel "${channelId}" with more than one argument which is not supported in MessageChannelListener yet.`, - ); - } - if (listeners.size === 0) { throw new Error( `Tried to send message to channel "${channelId}" but there where no listeners. Current channels with listeners: "${[ @@ -47,7 +41,7 @@ export const overrideMessagingFromMainToWindow = (mainDi: DiContainer) => { ); } - listeners.forEach((listener) => listener.handler(data[0])); + listeners.forEach((listener) => listener.handler(data)); }, ); diff --git a/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts b/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts index 125af6647b..52c7f9b377 100644 --- a/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts +++ b/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts @@ -4,14 +4,14 @@ */ import type { DiContainer } from "@ogre-tools/injectable"; import type { RequestChannel } from "../../common/utils/channel/request-channel-injection-token"; -import type { RequestChannelHandlerDescriptor } from "../../common/utils/channel/request-channel-listener-injection-token"; +import type { RequestChannelHandler } from "../../common/utils/channel/request-channel-listener-injection-token"; import enlistRequestChannelListenerInjectableInMain from "../../main/utils/channel/channel-listeners/enlist-request-channel-listener.injectable"; import requestFromChannelInjectable from "../../renderer/utils/channel/request-from-channel.injectable"; export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => { const requestChannelListenerFakesForMain = new Map< string, - RequestChannelHandlerDescriptor> + RequestChannelHandler> >(); mainDi.override( @@ -24,14 +24,7 @@ export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => { ); } - requestChannelListenerFakesForMain.set( - listener.channel.id, - - // TODO: Figure out typing - listener as unknown as RequestChannelHandlerDescriptor< - RequestChannel - >, - ); + requestChannelListenerFakesForMain.set(listener.channel.id, listener); return () => { requestChannelListenerFakesForMain.delete(listener.channel.id);