Skip to content

Commit

Permalink
Merge pull request #504 from audioverse-org/AV-705-Track-Actions-Search
Browse files Browse the repository at this point in the history
Av 705 track actions search
  • Loading branch information
jlaverde77 authored Dec 14, 2023
2 parents 01d4e2c + c2609cf commit c29fc38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions src/components/molecules/buttonPlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ export default function ButtonPlay({
prefersAudio?: boolean;
className?: string;
}): JSX.Element {
const { isPaused, play, pause, trackPlay, trackPause } = usePlaybackSession(
recording,
{
playlistRecordings,
prefersAudio,
}
);
const { isPaused, play, pause } = usePlaybackSession(recording, {
playlistRecordings,
prefersAudio,
});
const intl = useIntl();

const label = isPaused
Expand All @@ -73,9 +70,7 @@ export default function ButtonPlay({
? IconPauseLarge
: IconPause
}
onClick={() =>
isPaused ? (play(), trackPlay()) : (pause(), trackPause())
}
onClick={() => (isPaused ? play() : pause())}
color={
active
? isBackgroundColorDark(backgroundColor)
Expand Down
4 changes: 1 addition & 3 deletions src/components/molecules/player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ const Player = ({
(shouldShowPoster || posterHovered) && styles.posterPlayShown
)}
onClick={() =>
session.isPaused
? (session.play(), session.trackPlay())
: (session.pause(), session.trackPause())
session.isPaused ? session.play() : session.pause()
}
onTouchStart={() => setPosterHovered(true)}
onTouchEnd={() => setPosterHovered(false)}
Expand Down
7 changes: 5 additions & 2 deletions src/components/molecules/searchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import IconExit from '~public/img/icons/icon-exit.svg';
import IconSearch from '~public/img/icons/icon-search.svg';

import { analytics } from '../atoms/analytics';
import Mininav from './mininav';
import styles from './searchBar.module.scss';

Expand Down Expand Up @@ -54,7 +55,7 @@ export default function SearchBar({
return () => {
document.removeEventListener('keydown', handleSubmit);
};
}, [isFocused, handleSubmit]);
}, [isFocused, handleSubmit, term]);

useEffect(() => {
if (
Expand Down Expand Up @@ -85,7 +86,9 @@ export default function SearchBar({
value={term ?? ''}
onChange={({ target }) => onTermChange(target.value)}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
onBlur={() => {
setIsFocused(false), analytics.track('search', { term: term });
}}
placeholder={
isFocused
? ''
Expand Down
2 changes: 2 additions & 0 deletions src/lib/usePlaybackSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ export default function usePlaybackSession(
// TODO: Maybe only if `isLoaded` is true
// Or perhaps throw an exception, since the user should never be presented
// with a pause button for a recording that isn't loaded.
trackPause();
context.pause();
}

function play() {
afterLoad((c) => c.play());
trackPlay();
}

function setPrefersAudio(prefersAudio: boolean) {
Expand Down

1 comment on commit c29fc38

@vercel
Copy link

@vercel vercel bot commented on c29fc38 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.