From 5424730949e66555ebe6f6c1a360fd30a860e691 Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Tue, 22 Sep 2020 22:36:32 -0400 Subject: [PATCH] leap: destructure selection logic variables --- .../src/views/components/leap/Omnibox.js | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/pkg/interface/src/views/components/leap/Omnibox.js b/pkg/interface/src/views/components/leap/Omnibox.js index bedbee1dc..5f1323a28 100644 --- a/pkg/interface/src/views/components/leap/Omnibox.js +++ b/pkg/interface/src/views/components/leap/Omnibox.js @@ -179,18 +179,15 @@ export class Omnibox extends Component { }) ); if (currentIndex > 0) { - const nextApp = flattenedResults[currentIndex - 1].app; - const nextLink = flattenedResults[currentIndex - 1].link; - this.setState({ selected: [nextApp, nextLink] }); + const { app, link } = flattenedResults[currentIndex - 1]; + this.setState({ selected: [app, link] }); } else { - const nextApp = flattenedResults[totalLength - 1].app; - const nextLink = flattenedResults[totalLength - 1].link; - this.setState({ selected: [nextApp, nextLink] }); + const { app, link } = flattenedResults[totalLength - 1]; + this.setState({ selected: [app, link] }); } } else { - const nextApp = flattenedResults[totalLength - 1].app; - const nextLink = flattenedResults[totalLength - 1].link; - this.setState({ selected: [nextApp, nextLink] }); + const { app, link } = flattenedResults[totalLength - 1]; + this.setState({ selected: [app, link] }); } } @@ -204,18 +201,15 @@ export class Omnibox extends Component { }) ); if (currentIndex < flattenedResults.length - 1) { - const nextApp = flattenedResults[currentIndex + 1].app; - const nextLink = flattenedResults[currentIndex + 1].link; - this.setState({ selected: [nextApp, nextLink] }); + const { app, link } = flattenedResults[currentIndex + 1]; + this.setState({ selected: [app, link] }); } else { - const nextApp = flattenedResults[0].app; - const nextLink = flattenedResults[0].link; - this.setState({ selected: [nextApp, nextLink] }); + const { app, link } = flattenedResults[0]; + this.setState({ selected: [app, link] }); } } else { - const nextApp = flattenedResults[0].app; - const nextLink = flattenedResults[0].link; - this.setState({ selected: [nextApp, nextLink] }); + const { app, link } = flattenedResults[0]; + this.setState({ selected: [app, link] }); } }