Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the App.js #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getTokenFromResponse } from "./spotify";
import "./App.css";
import Login from "./Login";

const s = new SpotifyWebApi();
const spotify = new SpotifyWebApi();

function App() {
const [{ token }, dispatch] = useStateValue();
Expand All @@ -18,21 +18,21 @@ function App() {
let _token = hash.access_token;

if (_token) {
s.setAccessToken(_token);
spotify.setAccessToken(_token);

dispatch({
type: "SET_TOKEN",
token: _token,
});

s.getPlaylist("37i9dQZEVXcJZyENOWUFo7").then((response) =>
spotify.getPlaylist("37i9dQZEVXcJZyENOWUFo7").then((response) =>
dispatch({
type: "SET_DISCOVER_WEEKLY",
discover_weekly: response,
})
);

s.getMyTopArtists().then((response) =>
spotify.getMyTopArtists().then((response) =>
dispatch({
type: "SET_TOP_ARTISTS",
top_artists: response,
Expand All @@ -41,20 +41,20 @@ function App() {

dispatch({
type: "SET_SPOTIFY",
spotify: s,
spotify: spotify,
});

s.getMe().then((user) => {
spotify.getMe().then((user) => {
dispatch({
type: "SET_USER",
user,
});
});

s.getUserPlaylists().then((playlists) => {
spotify.getUserPlaylists().then((playlists) => {
dispatch({
type: "SET_PLAYLISTS",
playlists,
playlists:playlists,
});
});
}
Expand All @@ -63,7 +63,7 @@ function App() {
return (
<div className="app">
{!token && <Login />}
{token && <Player spotify={s} />}
{token && <Player spotify={spotify} />}
</div>
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import "./Header.css";
import { useStateValue } from "./StateProvider";
import { Avatar } from "@material-ui/core";
import SearchIcon from "@material-ui/icons/Search";
import { useEffect } from "react";

function Header({ spotify }) {
function Header() {
const [{ user }, dispatch] = useStateValue();

return (
<div className="header">
<div className="header__left">
Expand Down
2 changes: 1 addition & 1 deletion src/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function Login() {
return (
<div className="login">
<img
src="https://getheavy.com/wp-content/uploads/2019/12/spotify2019-830x350.jpg"
src="https://cdn.dribbble.com/users/441326/screenshots/3165191/spotify-gif---oliver-keane.gif"
alt=""
/>
<a href={accessUrl}>LOGIN TO SPOTIFY</a>
Expand Down