From 98e602f544b74ccf4014ee936926e2285b57f794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 9 Feb 2021 13:07:23 +0100 Subject: [PATCH 1/2] Avoid delayed displaying of sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .../views/elements/DesktopCapturerSourcePicker.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/views/elements/DesktopCapturerSourcePicker.tsx b/src/components/views/elements/DesktopCapturerSourcePicker.tsx index e53683b0ef..7197602fa4 100644 --- a/src/components/views/elements/DesktopCapturerSourcePicker.tsx +++ b/src/components/views/elements/DesktopCapturerSourcePicker.tsx @@ -85,6 +85,15 @@ export default class DesktopCapturerSourcePicker extends React.Component< } componentDidMount() { + // setInterval() first waits and then executes, therefore + // we call getDesktopCapturerSources() here without any delay. + // Otherwise the dialog would be left empty for some time. + getDesktopCapturerSources().then((result) => { + this.setState({ + sources: result, + }); + }); + // We update the sources every 500ms to get newer thumbnails this.interval = setInterval(async () => { this.setState({ From 27b2b5b65dbe14c30e24db2fc7aaeede57d6e37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 9 Feb 2021 13:19:12 +0100 Subject: [PATCH 2/2] Make componentDidMount async MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- .../views/elements/DesktopCapturerSourcePicker.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/DesktopCapturerSourcePicker.tsx b/src/components/views/elements/DesktopCapturerSourcePicker.tsx index 7197602fa4..6ae465c362 100644 --- a/src/components/views/elements/DesktopCapturerSourcePicker.tsx +++ b/src/components/views/elements/DesktopCapturerSourcePicker.tsx @@ -84,14 +84,12 @@ export default class DesktopCapturerSourcePicker extends React.Component< }; } - componentDidMount() { + async componentDidMount() { // setInterval() first waits and then executes, therefore // we call getDesktopCapturerSources() here without any delay. // Otherwise the dialog would be left empty for some time. - getDesktopCapturerSources().then((result) => { - this.setState({ - sources: result, - }); + this.setState({ + sources: await getDesktopCapturerSources(), }); // We update the sources every 500ms to get newer thumbnails