From 91a751f3f883dc9ff1dbc4dda6ca24beaa4f992e Mon Sep 17 00:00:00 2001 From: vapormusic Date: Thu, 18 Aug 2022 16:09:52 +0000 Subject: [PATCH] chore: Prettified Code [ci skip] --- src/main/plugins/raop.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/plugins/raop.ts b/src/main/plugins/raop.ts index 111f48eb..af2ea7a3 100644 --- a/src/main/plugins/raop.ts +++ b/src/main/plugins/raop.ts @@ -87,20 +87,19 @@ export default class RAOP { private ondeviceup(name: any, host: any, port: any, addresses: any, text: any, airplay2: any = null) { // console.log(this.castDevices.findIndex((item: any) => {return (item.name == host.replace(".local","") && item.port == port )})) - let shown_name = (host ?? "Unknown").replace(".local", "") + let shown_name = (host ?? "Unknown").replace(".local", ""); try { - let model = text.filter((u: any) => String(u).startsWith('model=')) - let manufacturer = text.filter((u: any) => String(u).startsWith('manufacturer=')) - let name1 = text.filter((u: any) => String(u).startsWith('name=')) + let model = text.filter((u: any) => String(u).startsWith("model=")); + let manufacturer = text.filter((u: any) => String(u).startsWith("manufacturer=")); + let name1 = text.filter((u: any) => String(u).startsWith("name=")); if (name1.length > 0) { - shown_name = name1[0].split("=")[1] + shown_name = name1[0].split("=")[1]; + } else if (manufacturer.length > 0) { + shown_name = (manufacturer.length > 0 ? manufacturer[0].substring(13) : "") + " " + (model.length > 0 ? model[0].substring(6) : ""); + shown_name = shown_name.trim().length > 1 ? shown_name : (host ?? "Unknown").replace(".local", ""); } - else if (manufacturer.length > 0) { - shown_name = (manufacturer.length > 0 ? manufacturer[0].substring(13) : "") + " " + (model.length > 0 ? model[0].substring(6) : "") - shown_name = (shown_name.trim()).length > 1 ? shown_name : (host ?? "Unknown").replace(".local", "") - } - } catch(e){} - let host_name = (addresses != null && typeof addresses == "object" && addresses.length > 0 ) ? addresses[0] : (typeof addresses == "string" ? addresses : ""); + } catch (e) {} + let host_name = addresses != null && typeof addresses == "object" && addresses.length > 0 ? addresses[0] : typeof addresses == "string" ? addresses : ""; if ( this.castDevices.findIndex((item: any) => {