From 564a9d26f9f7d81978863618f299cb7180368e2c Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Mon, 13 Apr 2020 09:55:11 -0400 Subject: [PATCH 1/2] Filter out "desktop" and "dynamic" in location (#193, HD-63 #in-review) --- src/utilities/settings.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utilities/settings.tsx b/src/utilities/settings.tsx index 5243875..0fdb752 100644 --- a/src/utilities/settings.tsx +++ b/src/utilities/settings.tsx @@ -133,16 +133,20 @@ export function createUserDefaults() { } /** - * Gets the configuration data from `config.json` + * Gets the configuration data from `config.json`. + * + * In scenarios where the app is being run from the desktop or from a local React server + * started by react-scripts, the location field is adjusted accordingly. + * * @returns The Promise data from getting the config. */ export async function getConfig(): Promise { try { const resp = await axios.get("config.json"); - let { location } = resp.data; + let { location }: { location: string } = resp.data; - if (!location.endsWith("/")) { + if (!location.endsWith("/") && (location !== "desktop" && location !== "dynamic")) { console.info( "Location does not have a backslash, so Hyperspace has added it automatically." ); From 1ec52d9d86ed4746420abeea2d1a6c3a01667709 Mon Sep 17 00:00:00 2001 From: Travis Kohlbeck Date: Tue, 14 Apr 2020 12:26:42 -0400 Subject: [PATCH 2/2] Modify console message slightly - Prettify if statement? --- src/utilities/settings.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utilities/settings.tsx b/src/utilities/settings.tsx index 0fdb752..3e97fac 100644 --- a/src/utilities/settings.tsx +++ b/src/utilities/settings.tsx @@ -146,9 +146,12 @@ export async function getConfig(): Promise { let { location }: { location: string } = resp.data; - if (!location.endsWith("/") && (location !== "desktop" && location !== "dynamic")) { + if ( + !location.endsWith("/") && + (location !== "desktop" && location !== "dynamic") + ) { console.info( - "Location does not have a backslash, so Hyperspace has added it automatically." + "Location does not have a forward slash, so Hyperspace has added it automatically." ); resp.data.location = location + "/"; }