Merge pull request #151 from matrix-org/vias

Pass args to clients
This commit is contained in:
Jorik Schellekens 2020-09-25 11:45:31 +01:00 committed by GitHub
commit 11fd9e1c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -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 {