Skip to content

Commit

Permalink
feat(episode): store hidden show in localstorage #10
Browse files Browse the repository at this point in the history
  • Loading branch information
rudywaltz committed May 30, 2019
1 parent fe5a423 commit fc2a4b5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
28 changes: 28 additions & 0 deletions cypress/integration/episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ describe('episode', () => {
cy.get('.archive > :nth-child(1) .episode__add_playlist').click();
cy.get('.archive > :nth-child(1) .episode__add_playlist')
.contains('Remove from Playlist');
cy.get('.archive > :nth-child(2) .episode__add_playlist').click();
cy.get('.archive > :nth-child(2) .episode__add_playlist')
.contains('Remove from Playlist');
cy.get('.archive > :nth-child(1) .episode__add_playlist').click();
cy.get('.player__toggle_playlist').click()
cy.get('.playlist')
Expand All @@ -44,4 +47,29 @@ describe('episode', () => {
expect($page).to.not.contain('Tilos Hírek');
});
})

it('should store hidden show list in localstorage', () => {
cy.get('.archive > :nth-child(3) .episode__hide_artist').click().should(() => {
expect(JSON.parse(localStorage.getItem('tilosStorehiddenShows')))
.to.deep.equal(['5480cee86dab254449a7cc7c']);
});
})

describe('localstorage', () => {
beforeEach(()=> {
cy.visit('/archive', {
onBeforeLoad: (contentWindow) => {
contentWindow.localStorage.clear();
contentWindow.localStorage
.setItem('tilosStorehiddenShows', JSON.stringify(['5480cee86dab254449a7cc7c']))
}
})
})

it('load data', () => {
cy.get('.archive').should($page => {
expect($page).to.not.contain('Tilos Hírek');
});
})
})
});
5 changes: 4 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import * as sapper from '@sapper/app';
import { playlist, song } from './components/stores';
import { playlist, song , hiddenShows } from './components/stores';
import { loadFromLocalStorage, saveToLocalStorage } from './use-local-storage.js';


loadFromLocalStorage(song, 'tilosStoreSong');
loadFromLocalStorage(playlist, 'tilosStorePlaylist');
loadFromLocalStorage(hiddenShows, 'tilosStorehiddenShows');

saveToLocalStorage(playlist, 'tilosStorePlaylist');
saveToLocalStorage(hiddenShows, 'tilosStorehiddenShows');


sapper.start({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Episode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export let text;
export let showId;
$: isInPlaylist = !!$playlist.find(song => song.url === mp3) || $song.url === mp3; // TODO or song?
$: isInPlaylist = !!$playlist.find(song => song.url === mp3) || $song.url === mp3;
$: hide = $hiddenShows.indexOf(showId) > -1;
const playlistToggle = () => {
Expand Down
3 changes: 0 additions & 3 deletions src/components/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
onDestroy(unsubscribe);
const createCurrentSong = () => {
const playing1 = playing;
return new Howl({
Expand Down Expand Up @@ -117,7 +115,6 @@
const target = event.target.getBoundingClientRect();
const position = event.pageX - target.left;
console.log('posi', position)
const rate = position / target.width;
currentSound.seek(rate * duration);
Expand Down

0 comments on commit fc2a4b5

Please sign in to comment.