Skip to content

Commit

Permalink
Merge pull request #10 from vtex-apps/hotfix/performance-issue
Browse files Browse the repository at this point in the history
Fixing performance issues
  • Loading branch information
wender authored Jul 14, 2020
2 parents 19f2e1b + 5907b2e commit c6808b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Performance issue

## [0.2.2] - 2020-07-14

### Removed
Expand Down
11 changes: 8 additions & 3 deletions react/AddProductBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const AddBtn: FC<any & WrappedComponentProps> = ({
data: { loading: sessionLoading, getSession },
intl,
}: any) => {

const [state, setState] = useState<any>({
isLoading: true,
isWishlisted: false,
Expand All @@ -65,6 +66,10 @@ const AddBtn: FC<any & WrappedComponentProps> = ({
const { navigate, history } = useRuntime()
const client = useApolloClient()
const handles = useCssHandles(CSS_HANDLES)
const { showToast } = useContext(ToastContext)
const { product } = useContext(ProductContext) as any

if(!product) return null

const toastMessage = (messsageKey: string) => {
let action: any = undefined
Expand Down Expand Up @@ -94,15 +99,15 @@ const AddBtn: FC<any & WrappedComponentProps> = ({
action,
})
}
const { showToast } = useContext(ToastContext)


const { isLoading, isWishlisted, wishListId } = state

if (getSession?.profile && !isAuthenticated) {
isAuthenticated = getSession.profile.email
}

const { product } = useContext(ProductContext) as any


const getIdFromList = (list: string, item: any) => {
const pos = item.listNames.findIndex((listName: string) => {
Expand Down Expand Up @@ -142,7 +147,7 @@ const AddBtn: FC<any & WrappedComponentProps> = ({
})
}
} else {
if(!isAuthenticated) {
if(!isAuthenticated && state.isLoading) {
setState({
...state,
isLoading: false,
Expand Down

0 comments on commit c6808b7

Please sign in to comment.