Automaitcally copy invite information
This commit is contained in:
parent
154f82f7d4
commit
4921513e13
4 changed files with 23 additions and 1 deletions
|
@ -57,6 +57,17 @@ const Weechat: TextClient = {
|
||||||
return <span>Weechat doesn't support this kind of link</span>;
|
return <span>Weechat doesn't support this kind of link</span>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
copyString: (link) => {
|
||||||
|
switch (link.kind) {
|
||||||
|
case LinkKind.Alias:
|
||||||
|
case LinkKind.RoomId:
|
||||||
|
return `/join ${link.identifier}`;
|
||||||
|
case LinkKind.UserId:
|
||||||
|
return `/invite ${link.identifier}`;
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
description: 'Commandline Matrix interface using Weechat',
|
description: 'Commandline Matrix interface using Weechat',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ export interface LinkedClient extends ClientDescription {
|
||||||
export interface TextClient extends ClientDescription {
|
export interface TextClient extends ClientDescription {
|
||||||
kind: ClientKind.TEXT_CLIENT;
|
kind: ClientKind.TEXT_CLIENT;
|
||||||
toInviteString(parsedLink: SafeLink): JSX.Element;
|
toInviteString(parsedLink: SafeLink): JSX.Element;
|
||||||
|
copyString(parsedLink: SafeLink): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -42,7 +42,16 @@ const ClientTile: React.FC<IProps> = ({ client, link }: IProps) => {
|
||||||
const inviteButton =
|
const inviteButton =
|
||||||
client.kind === ClientKind.LINKED_CLIENT ? (
|
client.kind === ClientKind.LINKED_CLIENT ? (
|
||||||
<Button>Accept invite</Button>
|
<Button>Accept invite</Button>
|
||||||
) : null;
|
) : (
|
||||||
|
<Button
|
||||||
|
onClick={() =>
|
||||||
|
navigator.clipboard.writeText(client.copyString(link))
|
||||||
|
}
|
||||||
|
flashChildren="Invite copied"
|
||||||
|
>
|
||||||
|
Copy invite
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
let clientTile = (
|
let clientTile = (
|
||||||
<Tile className={className}>
|
<Tile className={className}>
|
||||||
|
|
|
@ -61,6 +61,7 @@ const InviteTile: React.FC<IProps> = ({ children, client, link }: IProps) => {
|
||||||
case ClientKind.TEXT_CLIENT:
|
case ClientKind.TEXT_CLIENT:
|
||||||
// TODO: copy to clipboard
|
// TODO: copy to clipboard
|
||||||
invite = <p>{client.toInviteString(link)}</p>;
|
invite = <p>{client.toInviteString(link)}</p>;
|
||||||
|
navigator.clipboard.writeText(client.copyString(link));
|
||||||
inviteUseString = `These are instructions for ${client.name}.`;
|
inviteUseString = `These are instructions for ${client.name}.`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue