From 90b4fbe5832252607dd2f56506b23fee9e15b966 Mon Sep 17 00:00:00 2001 From: Yuan Gong Date: Sun, 23 Feb 2020 13:44:56 +0800 Subject: [PATCH] Add optional chaining examplee --- frontend/src/pages/GettingStarted.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/GettingStarted.tsx b/frontend/src/pages/GettingStarted.tsx index 1603e777e94c..1597fa023e84 100644 --- a/frontend/src/pages/GettingStarted.tsx +++ b/frontend/src/pages/GettingStarted.tsx @@ -129,14 +129,11 @@ export class GettingStarted extends Page<{}, { links: string[] }> { .listPipelines(undefined, 10, undefined, createAndEncodeFilter(name)) .then(pipelineList => { const pipelines = pipelineList.pipelines; - if (!pipelines || pipelines.length !== 1) { + if (pipelines?.length !== 1) { + // We only return the id when we can accurately identified it. return ''; } - const pipeline = pipelines[0]; - if (!pipeline.id) { - return ''; - } - return pipeline.id; + return pipelines[0].id || ''; }) .catch(() => ''), ),