Skip to content

Commit

Permalink
💄 Show login button only if not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
jh0ker committed Apr 3, 2018
1 parent 90257ae commit 04673e5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/view-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import saga from '../sagas/view-home';
import {Views} from "../routing";
import {register} from "../sagas/routing";
import {State} from "../state";
import {loadAuthData} from "../util/spotify";

register(Views.Home, saga);

interface ViewHomeProps {
playlists: any[];
loggedIn: boolean;
}

interface ViewHomeDispatch {
loginSpotify: typeof loginSpotify;
}

const View = (props: ViewHomeProps & ViewHomeDispatch) => html`
<button on-click="${ props.loginSpotify }">Login via Spotify</button>
${!props.loggedIn ? html`<button on-click="${ props.loginSpotify }">Login via Spotify</button>` : ''}
<ol>
${props.playlists.map((playlist) => html`
<li>${playlist.name}</li>
Expand All @@ -27,6 +29,7 @@ ${props.playlists.map((playlist) => html`

const mapStateToProps = (state: State): ViewHomeProps => ({
playlists: Object.values(state.playlistsSpotify),
loggedIn: !!loadAuthData(),
});

const mapDispatchToProps: ViewHomeDispatch = {
Expand Down

0 comments on commit 04673e5

Please sign in to comment.