From f4c48bc94f2146eac45e1d85a9c30979552f6d55 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 15 Jun 2018 21:51:50 +0200 Subject: [PATCH] Fixed loading state in servers list --- src/short-urls/ShortUrlsList.js | 5 +++-- src/short-urls/reducers/shortUrlsList.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/short-urls/ShortUrlsList.js b/src/short-urls/ShortUrlsList.js index 3a4f3d19..e4907a67 100644 --- a/src/short-urls/ShortUrlsList.js +++ b/src/short-urls/ShortUrlsList.js @@ -1,6 +1,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { listShortUrls } from './reducers/shortUrlsList'; +import { isEmpty } from 'ramda'; export class ShortUrlsList extends React.Component { componentDidMount() { @@ -18,8 +19,8 @@ export class ShortUrlsList extends React.Component { renderShortUrls() { const { shortUrlsList } = this.props; - if (! shortUrlsList) { - return '
  • Loading...
  • '; + if (isEmpty(shortUrlsList)) { + return
  • Loading...
  • ; } return shortUrlsList.map(shortUrl => ( diff --git a/src/short-urls/reducers/shortUrlsList.js b/src/short-urls/reducers/shortUrlsList.js index 71bbbc36..f739b0b6 100644 --- a/src/short-urls/reducers/shortUrlsList.js +++ b/src/short-urls/reducers/shortUrlsList.js @@ -16,6 +16,7 @@ export const listShortUrls = (serverId) => { const selectedServer = ServersService.findServerById(serverId); ShlinkApiClient.setConfig(selectedServer); - dispatch({ type: LIST_SHORT_URLS, shortUrls: await ShlinkApiClient.listShortUrls() }); + const shortUrls = await ShlinkApiClient.listShortUrls(); + dispatch({ type: LIST_SHORT_URLS, shortUrls }); }; };