From 5cd5910386427a00cbd6abf03d647ab8194a16f0 Mon Sep 17 00:00:00 2001 From: Onuwa Nnachi Isaac Date: Fri, 17 May 2019 20:42:00 +0100 Subject: [PATCH] Fix profile bug --- src/modules/Profile/Profile.jsx | 65 ++++++++++++++------------ src/modules/Profile/Profile.reducer.js | 9 ++-- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/modules/Profile/Profile.jsx b/src/modules/Profile/Profile.jsx index 0bb1138..4d85fd3 100644 --- a/src/modules/Profile/Profile.jsx +++ b/src/modules/Profile/Profile.jsx @@ -1,11 +1,11 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import ReactImageFallback from 'react-image-fallback' +import { push } from 'connected-react-router' import Modal from '../../common/components/Modal' import styles from './Profile.module.scss' import icon from '../../common/assets/images/icon.svg' import chat from '../../common/assets/images/chat.svg' -import { push } from 'connected-react-router' const DesktopScreen = props => { return {props.children} @@ -53,11 +53,9 @@ const ProfileContent = ({ alt="App icon" /> Chat - {`Open ${name} chat`} + + {`Open ${name} chat`} +
URL @@ -100,39 +98,48 @@ class Profile extends Component { this.state = { screenSize: 0, visible: true, - dapp: {}, } } componentDidMount() { const { innerWidth } = window - const { dapp_name } = this.props.match.params + const { match, openModal } = this.props + const { params } = match + const { dapp_name } = params + if (innerWidth >= 1024) { + openModal(dapp_name) + } - // in order to access dapps list please use this.props.dapps.dapps. Also have in mind that this list might be null at the beginning - this.props.dapps.find(dapp => { - if (dapp.name.toLowerCase() === dapp_name.toLowerCase()) { - if (innerWidth >= 1024) { - this.props.openModal(dapp.name) - } - this.setState({ - screenSize: innerWidth, - visible: true, - dapp, - }) - } + this.setState({ + screenSize: innerWidth, + visible: true, }) } render() { - return this.state.screenSize >= 1024 ? ( - - - - ) : ( - - - - ) + const { match, dapps } = this.props + const { params } = match + const { dapp_name } = params + + const { screenSize, visible } = this.state + if ( + dapps.highestRankedFetched === true && + dapps.recentlyAddedFetched === true + ) { + const dapp = dapps.dapps.find(item => + item.name.toLowerCase() === dapp_name.toLowerCase() ? item : '', + ) + return screenSize >= 1024 ? ( + + + + ) : ( + + + + ) + } + return null } } Profile.propTypes = { diff --git a/src/modules/Profile/Profile.reducer.js b/src/modules/Profile/Profile.reducer.js index 03c66db..bb049cd 100644 --- a/src/modules/Profile/Profile.reducer.js +++ b/src/modules/Profile/Profile.reducer.js @@ -13,11 +13,10 @@ export const toggleProfileModalAction = dapp => { type: MOBILE_NAVIGATE, payload: dapp, } - } else { - return { - type: DESKTOP_NAVIGATE, - payload: dapp, - } + } + return { + type: DESKTOP_NAVIGATE, + payload: dapp, } }