Skip to content

Commit

Permalink
feat(user): clear blurimage when entering user screen
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed Jul 22, 2021
1 parent 9b92e2d commit 9fdaf4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/hooks/useBlurImageUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ const useBlurImageUpdater = (data?: PlaylistItem[] | PlaylistItem) => {
}, [data]);

return useCallback((image: string) => {
if (image) {
UIStore.update((state) => {
state.blurImage = image;
});
}
UIStore.update((state) => {
state.blurImage = image;
});
}, []);
};

Expand Down
12 changes: 7 additions & 5 deletions src/screens/User/User.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { Redirect, Route, Switch, useHistory } from 'react-router-dom';
import type { PlaylistItem } from 'types/playlist';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -33,13 +33,15 @@ const User = (): JSX.Element => {
const updateBlurImage = useBlurImageUpdater();
const { clearList: clearFavorites } = useFavorites();

if (!customer) {
return <div className={styles.user}>Open login panel?</div>;
}

const onCardClick = (playlistItem: PlaylistItem) => history.push(cardUrl(playlistItem));
const onCardHover = (playlistItem: PlaylistItem) => updateBlurImage(playlistItem.image);

useEffect(() => updateBlurImage(''), [updateBlurImage]);

if (!customer) {
return <div className={styles.user}>Please login first</div>;
}

return (
<div className={styles.user}>
{isLargeScreen && (
Expand Down

0 comments on commit 9fdaf4e

Please sign in to comment.