From fc052e6fae601dab7f8e3e2f3ca2c8775b951114 Mon Sep 17 00:00:00 2001 From: Jorik Schellekens Date: Thu, 24 Sep 2020 11:11:07 +0100 Subject: [PATCH] Pass args to client --- src/clients/Element.io.ts | 10 ++++++---- src/components/HomeserverOptions.stories.tsx | 2 +- src/components/InviteTile.stories.tsx | 2 ++ src/components/LinkPreview.tsx | 4 ++-- src/parser/parser.ts | 1 + src/parser/types.ts | 2 ++ 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/clients/Element.io.ts b/src/clients/Element.io.ts index 8a346ae..2550840 100644 --- a/src/clients/Element.io.ts +++ b/src/clients/Element.io.ts @@ -36,23 +36,25 @@ const Element: LinkedClient = { experimental: false, clientId: ClientId.Element, toUrl: (link) => { + const params = link.arguments.originalParams.toString(); + const prefixedParams = params ? `?${params}` : ''; switch (link.kind) { case LinkKind.Alias: case LinkKind.RoomId: return new URL( - `https://app.element.io/#/room/${link.identifier}` + `https://app.element.io/#/room/${link.identifier}${prefixedParams}` ); case LinkKind.UserId: return new URL( - `https://app.element.io/#/user/${link.identifier}` + `https://app.element.io/#/user/${link.identifier}${prefixedParams}` ); case LinkKind.Permalink: return new URL( - `https://app.element.io/#/room/${link.identifier}` + `https://app.element.io/#/room/${link.identifier}${prefixedParams}` ); case LinkKind.GroupId: return new URL( - `https://app.element.io/#/group/${link.identifier}` + `https://app.element.io/#/group/${link.identifier}${prefixedParams}` ); } }, diff --git a/src/components/HomeserverOptions.stories.tsx b/src/components/HomeserverOptions.stories.tsx index 8a75042..b6e112e 100644 --- a/src/components/HomeserverOptions.stories.tsx +++ b/src/components/HomeserverOptions.stories.tsx @@ -34,7 +34,7 @@ export const Default: React.FC = () => ( = ({ link }: IProps) => { let content: JSX.Element; const [showHSOptions, setShowHSOPtions] = useState(false); - const hses = useHSs({link}); + const hses = useHSs({ link }); if (!hses.length) { content = ( @@ -169,7 +169,7 @@ const LinkPreview: React.FC = ({ link }: IProps) => { link={{ kind: LinkKind.UserId, identifier: link.arguments.sharer, - arguments: { vias: [] }, + arguments: { vias: [], originalParams: new URLSearchParams() }, originalLink: '', }} /> diff --git a/src/parser/parser.ts b/src/parser/parser.ts index 6461b27..89b2b9c 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -92,6 +92,7 @@ export function parseArgs(args: string): Arguments { vias: params.getAll('via'), client: bottomExchange(params.get('client')), sharer: bottomExchange(params.get('sharer')), + originalParams: params, }; } diff --git a/src/parser/types.ts b/src/parser/types.ts index 5d8fa79..5cc5cc8 100644 --- a/src/parser/types.ts +++ b/src/parser/types.ts @@ -4,6 +4,8 @@ export interface Arguments { client?: string; // MXID sharer?: string; + // Original params + originalParams: URLSearchParams; } export interface LinkContent {