Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit af3e1633 authored by Simon Chan's avatar Simon Chan
Browse files

fix(demo): fix disconnection detect

parent 24e47d3a
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -169,11 +169,11 @@ function _Connect(): JSX.Element | null {
            return;
        }

        function dispose() {
        async function dispose() {
            // Adb won't close the streams,
            // so manually close them.
            try { readable.cancel(); } catch { }
            try { writable.close(); } catch { }
            try { await writable.close(); } catch { }
            globalState.setDevice(undefined, undefined);
        }

@@ -184,17 +184,17 @@ function _Connect(): JSX.Element | null {
                undefined
            );

            device.disconnected.then(() => {
                dispose();
            }, (e) => {
            device.disconnected.then(async () => {
                await dispose();
            }, async (e) => {
                globalState.showErrorDialog(e);
                dispose();
                await dispose();
            });

            globalState.setDevice(selectedBackend, device);
        } catch (e: any) {
            globalState.showErrorDialog(e);
            dispose();
            await dispose();
        } finally {
            setConnecting(false);
        }