Skip to content

Commit

Permalink
feat(episode): hide similar artist #10
Browse files Browse the repository at this point in the history
  • Loading branch information
rudywaltz committed May 26, 2019
1 parent 504638a commit 793961f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
7 changes: 7 additions & 0 deletions cypress/integration/episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ describe('episode', () => {
cy.get('.playlist')
.contains('Choose one song')
})

it('should hide similar artist', () => {
cy.get('.archive > :nth-child(3) .episode__hide_artist').click()
cy.get('.archive').should($page => {
expect($page).to.not.contain('Tilos Hírek');
});
})
});
28 changes: 19 additions & 9 deletions src/components/Episode.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script>
import { format } from '../helpers';
import { playlist } from './stores';
import { playlist, hiddenShows } from './stores';
export let name;
export let mp3;
export let duration;
export let text;
export let showId;
$: isInPlaylist = !!$playlist.find(song => song.url === mp3);
$: hide = $hiddenShows.indexOf(showId) > -1;
const playlistToggle = () => {
if (isInPlaylist) {
Expand All @@ -20,6 +21,10 @@
}];
}
}
const hideArtist = () => {
$hiddenShows = [...$hiddenShows, showId];
}
</script>

<style>
Expand All @@ -41,10 +46,15 @@
}
</style>

<div class="episode archive__item">
<h2 class="episode__title">{name}</h2>
<time class="episode__duration">{format(duration)}</time>
<p class="episode__diary">{text}</p>
<code class="episode__link">{mp3}</code>
<button type="submit" on:click={playlistToggle} class="episode__add_playlist">{isInPlaylist ? 'Remove from Playlist' : 'Add to Playlist'}</button>
</div>
{#if !hide}
<div class="episode archive__item">
<h2 class="episode__title">{name}</h2>
<time class="episode__duration">{format(duration)}</time>
<p class="episode__diary">{text}</p>
<code class="episode__link">{mp3}</code>
<br>
<button type="button" on:click={playlistToggle} class="episode__add_playlist">{isInPlaylist ? 'Remove from Playlist' : 'Add to Playlist'}</button>
<br>
<button type="button" on:click={hideArtist} class="episode__hide_artist">Hide this Artist</button>
</div>
{/if}
1 change: 1 addition & 0 deletions src/routes/archive.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
episodes.forEach(episode => {
newEpisodes.push({
name: episode.show.name,
showId: episode.show.id,
text: episode.text ? episode.text.title : '------',
mp3: episode.m3uUrl.slice(0, -3) + 'mp3',
duration: (episode.realTo - episode.realFrom) / 1000
Expand Down

0 comments on commit 793961f

Please sign in to comment.