From 045cc0d243ccdad6f02fe8c4bd4d5a7ea084d1ca Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 30 Mar 2020 11:00:48 +0200 Subject: [PATCH] fixed serial modal crash (#2278) --- .../src/services/serial.service.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/terminus-serial/src/services/serial.service.ts b/terminus-serial/src/services/serial.service.ts index f1fb9088..6cd540dc 100644 --- a/terminus-serial/src/services/serial.service.ts +++ b/terminus-serial/src/services/serial.service.ts @@ -64,23 +64,25 @@ export class SerialService { async showConnectionSelector (): Promise { const options: SelectorOption[] = [] - const lastConnection = JSON.parse(window.localStorage.lastSerialConnection) const foundPorts = await this.listPorts() - if (lastConnection) { - options.push({ - name: lastConnection.name, - icon: 'history', - callback: () => this.connect(lastConnection), - }) - options.push({ - name: 'Clear last connection', - icon: 'eraser', - callback: () => { - window.localStorage.lastSerialConnection = null - }, - }) - } + try { + const lastConnection = JSON.parse(window.localStorage.lastSerialConnection) + if (lastConnection) { + options.push({ + name: lastConnection.name, + icon: 'history', + callback: () => this.connect(lastConnection), + }) + options.push({ + name: 'Clear last connection', + icon: 'eraser', + callback: () => { + window.localStorage.lastSerialConnection = null + }, + }) + } + } catch { } for (const port of foundPorts) { options.push({