Pass args to client

This commit is contained in:
Jorik Schellekens 2020-09-24 11:11:07 +01:00
parent 32c6119243
commit fc052e6fae
6 changed files with 14 additions and 7 deletions

View file

@ -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}`
);
}
},

View file

@ -34,7 +34,7 @@ export const Default: React.FC = () => (
<HomeserverOptions
link={{
identifier: '#banter:matrix.org',
arguments: { vias: [] },
arguments: { vias: [], originalParams: new URLSearchParams() },
kind: LinkKind.Alias,
originalLink: 'This is all made up',
}}

View file

@ -42,6 +42,7 @@ const userLink: SafeLink = {
identifier: '@jorik:matrix.org',
arguments: {
vias: [],
originalParams: new URLSearchParams(),
},
originalLink: 'asdfsadf',
};
@ -51,6 +52,7 @@ const roomLink: SafeLink = {
identifier: '#element-dev:matrix.org',
arguments: {
vias: [],
originalParams: new URLSearchParams(),
},
originalLink: 'asdfsadf',
};

View file

@ -127,7 +127,7 @@ const LinkPreview: React.FC<IProps> = ({ 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<IProps> = ({ link }: IProps) => {
link={{
kind: LinkKind.UserId,
identifier: link.arguments.sharer,
arguments: { vias: [] },
arguments: { vias: [], originalParams: new URLSearchParams() },
originalLink: '',
}}
/>

View file

@ -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,
};
}

View file

@ -4,6 +4,8 @@ export interface Arguments {
client?: string;
// MXID
sharer?: string;
// Original params
originalParams: URLSearchParams;
}
export interface LinkContent {