System clipboard (#2117)

This commit is contained in:
David Luzar
2020-09-04 14:58:32 +02:00
committed by GitHub
parent 950ec66907
commit 47dba05c91
7 changed files with 155 additions and 91 deletions

View File

@@ -16,6 +16,7 @@ const RoomModal = ({
onRoomCreate,
onRoomDestroy,
onPressingEnter,
setErrorMessage,
}: {
activeRoomLink: string;
username: string;
@@ -23,11 +24,16 @@ const RoomModal = ({
onRoomCreate: () => void;
onRoomDestroy: () => void;
onPressingEnter: () => void;
setErrorMessage: (message: string) => void;
}) => {
const roomLinkInput = useRef<HTMLInputElement>(null);
const copyRoomLink = () => {
copyTextToSystemClipboard(activeRoomLink);
const copyRoomLink = async () => {
try {
await copyTextToSystemClipboard(activeRoomLink);
} catch (error) {
setErrorMessage(error.message);
}
if (roomLinkInput.current) {
roomLinkInput.current.select();
}
@@ -127,6 +133,7 @@ export const RoomDialog = ({
onUsernameChange,
onRoomCreate,
onRoomDestroy,
setErrorMessage,
}: {
isCollaborating: AppState["isCollaborating"];
collaboratorCount: number;
@@ -134,6 +141,7 @@ export const RoomDialog = ({
onUsernameChange: (username: string) => void;
onRoomCreate: () => void;
onRoomDestroy: () => void;
setErrorMessage: (message: string) => void;
}) => {
const [modalIsShown, setModalIsShown] = useState(false);
const [activeRoomLink, setActiveRoomLink] = useState("");
@@ -182,6 +190,7 @@ export const RoomDialog = ({
onRoomCreate={onRoomCreate}
onRoomDestroy={onRoomDestroy}
onPressingEnter={handleClose}
setErrorMessage={setErrorMessage}
/>
</Dialog>
)}