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

Move components to TS #2 #438

Merged
merged 59 commits into from
Aug 22, 2019
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
487fc5c
Move loaders to TS
raphaelvigee Aug 4, 2019
5a9f607
Move VolumeControl to TS
raphaelvigee Aug 4, 2019
d65c2a5
Move player to TS
raphaelvigee Aug 5, 2019
90ccca4
Move Translations to TS
raphaelvigee Aug 5, 2019
808a787
Move tabs to TS
raphaelvigee Aug 5, 2019
f00c1b8
Move Splashscreen to TS
raphaelvigee Aug 5, 2019
88c6436
Move TrackContextMenu to TS
raphaelvigee Aug 5, 2019
bcae48e
Move ItemList to TS
raphaelvigee Aug 5, 2019
9f3f6f7
Move AlbumItem to TS
raphaelvigee Aug 5, 2019
ccc7641
Move lbumContextMenu to TS
raphaelvigee Aug 5, 2019
f3d7362
Move AlbumPanel to TS
raphaelvigee Aug 5, 2019
b6ac786
Move NavigationBar to TS
raphaelvigee Aug 5, 2019
0034e4c
Move Rating to TS
raphaelvigee Aug 5, 2019
6b0a403
Move TopCharts to TS
raphaelvigee Aug 5, 2019
4965f82
Move MenuItem to TS
raphaelvigee Aug 5, 2019
d584946
Move PlaylistContextMenu to TS
raphaelvigee Aug 5, 2019
39656f8
Move contextmenu & tracklistitem to TS
raphaelvigee Aug 5, 2019
aabf253
Move artistItem to TS
raphaelvigee Aug 5, 2019
b12c052
Move resultItem to TS
raphaelvigee Aug 5, 2019
e776514
Move searchbar to TS
raphaelvigee Aug 6, 2019
97674d8
Move CuratorItem to TS
raphaelvigee Aug 7, 2019
9dbf731
Move ArtistAlbums to TS
raphaelvigee Aug 7, 2019
76de499
Move ArtistsList to TS
raphaelvigee Aug 9, 2019
4cb6727
Move GenteItem to TS
raphaelvigee Aug 9, 2019
c91a52a
Move PlaylistItem to TS
raphaelvigee Aug 9, 2019
eadddbc
Move some more stuff to TS
raphaelvigee Aug 10, 2019
40b6cb6
Move AuthorizeProvider to TS
raphaelvigee Aug 15, 2019
b38649a
Move SongsPage to TS
raphaelvigee Aug 15, 2019
eee86f6
Move Sidebar & PlaylistProvider to TS
raphaelvigee Aug 15, 2019
f51a031
Move SidebarMenu to TS
raphaelvigee Aug 15, 2019
a5c16f0
Move Lyrics & LyricsMOdal to TS
raphaelvigee Aug 15, 2019
f965717
Move MusicKitProvider to TS
raphaelvigee Aug 15, 2019
ea16072
Move PageContent to TS
raphaelvigee Aug 15, 2019
c737bcc
Move RadioPage to TS
raphaelvigee Aug 15, 2019
9d30793
Move PlaylistSelectcor to TS
raphaelvigee Aug 15, 2019
29c4260
Move PlaylistPanel to TS
raphaelvigee Aug 15, 2019
b19cc0a
Move PlaylistPage to TS
raphaelvigee Aug 15, 2019
1783ca5
Move PlaylistsPage to TS & fix HOCs
raphaelvigee Aug 15, 2019
d350481
Move SentryBoundary to TS
raphaelvigee Aug 15, 2019
d65d1ab
Move GAProvider to TS
raphaelvigee Aug 15, 2019
8df1db1
Move LastfmProvider to TS
raphaelvigee Aug 15, 2019
46de869
Move Genres to TS
raphaelvigee Aug 15, 2019
cac7a48
Move GenrePage to TS
raphaelvigee Aug 15, 2019
ac2f5bf
Move ForYouPage to TS
raphaelvigee Aug 15, 2019
f96f026
Move BrowsePage to TS
raphaelvigee Aug 15, 2019
74efeab
Move AuthorizeButton to TS
raphaelvigee Aug 15, 2019
30f70ff
Move ArtistPage to TS
raphaelvigee Aug 15, 2019
def85d5
Move ArtistsPage to TS
raphaelvigee Aug 15, 2019
1b8a61e
Move AlbumsPage to TS
raphaelvigee Aug 15, 2019
ba07836
Move Settings to TS
raphaelvigee Aug 15, 2019
b204275
Move SearchPage to TS
raphaelvigee Aug 15, 2019
48d4fd3
Move RecentlyAdded to TS
raphaelvigee Aug 15, 2019
e87de68
Move Layout to TS
raphaelvigee Aug 15, 2019
eb3b350
MOve App to TS
raphaelvigee Aug 15, 2019
ff155f9
Move index to TS
raphaelvigee Aug 15, 2019
13ae907
Move AlbumPage to TS
raphaelvigee Aug 15, 2019
8194e52
Move remainig js to ts & disallow js
raphaelvigee Aug 15, 2019
8a3eaf4
Disable Interface starting with capitalized I
raphaelvigee Aug 16, 2019
10c8d8b
Prevent type copy/paste
raphaelvigee Aug 21, 2019
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
Prev Previous commit
Next Next commit
Move ForYouPage to TS
  • Loading branch information
raphaelvigee committed Aug 15, 2019
commit ac2f5bfeb23b4fe9a33a9c7a41b5fbdf9ef42538
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
import cx from 'classnames';
import React from 'react';
import { RouteComponentProps } from 'react-router';
import { withRouter } from 'react-router-dom';
import cx from 'classnames';
import translate from '../../../../utils/translations/Translations';
import AlbumItem from '../../../Common/AlbumItem/AlbumItem';
import Loader from '../../../Common/Loader/Loader';
import PageContent from '../../../Common/PageContent/PageContent';
import PageTitle from '../../../Common/PageTitle/PageTitle';
import classes from './ForYouPage.scss';
import Loader from '../../../Common/Loader/Loader';
import AlbumItem from '../../../Common/AlbumItem/AlbumItem';
import PlaylistItem from '../../../Common/PlaylistItem/PlaylistItem';
import translate from '../../../../utils/translations/Translations';
import classes from './ForYouPage.scss';

type IForYouPageProps = RouteComponentProps;

interface IForYouPageState {
heavyRotation: any;
recentlyPlayed: any;
recommendations: any;
}

type RecentlyPlayedItem = any;
type HeavyRotationItem = any;
type RecommendationGroup = any;
type RecommendationGroupItem = any;

class ForYouPage extends React.Component {
constructor(props) {
class ForYouPage extends React.Component<IForYouPageProps, IForYouPageState> {
public readonly ref = React.createRef<HTMLDivElement>();

constructor(props: IForYouPageProps) {
super(props);

this.state = {
heavyRotation: null,
recentlyPlayed: null,
recommendations: null,
};

this.ref = React.createRef();
}

async componentDidMount() {
public async componentDidMount() {
const music = MusicKit.getInstance();

let heavyRotation;
Expand All @@ -41,6 +55,7 @@ class ForYouPage extends React.Component {

let recommendations;
try {
// @ts-ignore Incorrect type signature
recommendations = await music.api.recommendations();
} catch (error) {
recommendations = false;
Expand All @@ -53,7 +68,7 @@ class ForYouPage extends React.Component {
});
}

renderRecentlyPlayed = () => {
public renderRecentlyPlayed = () => {
const { recentlyPlayed } = this.state;

if (recentlyPlayed === false) {
Expand All @@ -69,7 +84,7 @@ class ForYouPage extends React.Component {
<h3>{translate.recentlyPlayed}</h3>
<div className={cx(classes.scrollWrapper)}>
<div className={classes.scrollGrid}>
{recentlyPlayed.map(item => {
{recentlyPlayed.map((item: RecentlyPlayedItem) => {
switch (item.type) {
case 'playlists':
return <PlaylistItem key={item.id} playlist={item} size={120} />;
Expand All @@ -85,7 +100,7 @@ class ForYouPage extends React.Component {
);
};

renderHeavyRotation = () => {
public renderHeavyRotation = () => {
const { heavyRotation } = this.state;

if (heavyRotation === false) {
Expand All @@ -101,7 +116,7 @@ class ForYouPage extends React.Component {
<h3>{translate.heavyRotation}</h3>
<div className={classes.scrollWrapper}>
<div className={classes.scrollGrid}>
{heavyRotation.map(item => {
{heavyRotation.map((item: HeavyRotationItem) => {
switch (item.type) {
case 'playlists':
return <PlaylistItem key={item.id} playlist={item} size={120} />;
Expand All @@ -117,7 +132,7 @@ class ForYouPage extends React.Component {
);
};

renderRecommendations = () => {
public renderRecommendations = () => {
const { recommendations } = this.state;

if (recommendations === false) {
Expand All @@ -128,7 +143,7 @@ class ForYouPage extends React.Component {
return null; // Loading items
}

function renderGroup(group) {
function renderGroup(group: RecommendationGroup) {
const { relationships } = group;

if (!relationships) {
Expand All @@ -140,7 +155,9 @@ class ForYouPage extends React.Component {
const shouldRenderLegacyGroup = !!group.attributes.title;

if (isGroup && !shouldRenderLegacyGroup) {
return relationships.recommendations.data.map(nestedGroup => renderGroup(nestedGroup));
return relationships.recommendations.data.map((nestedGroup: RecommendationGroup) =>
renderGroup(nestedGroup),
);
}

const id = group.attributes.title.stringForDisplay; // TODO: switch back to group.id?
Expand All @@ -149,9 +166,9 @@ class ForYouPage extends React.Component {
<React.Fragment key={id}>
<h3>{group.attributes.title.stringForDisplay}</h3>
<div className={cx(classes.scrollWrapper)}>
<div className={cx(classes.scrollWrapper, { [classes.groupedScroller]: isGroup })}>
<div className={cx(classes.scrollWrapper)}>
<div className={classes.scrollGrid}>
{items.data.map(item => {
{items.data.map((item: RecommendationGroupItem) => {
switch (item.type) {
case 'playlists':
return <PlaylistItem key={item.id} playlist={item} size={120} />;
Expand All @@ -168,17 +185,21 @@ class ForYouPage extends React.Component {
{recommendationName}
</span>
<div className={classes.personalRecommendationsGrid}>
{item.relationships.contents.data.map(subItem => {
const subId = `${item.id}-${subItem.id}`;
switch (subItem.type) {
case 'playlists':
return <PlaylistItem key={subId} playlist={subItem} size={100} />;
case 'albums':
return <AlbumItem key={subId} album={subItem} size={100} />;
default:
return null;
}
})}
{item.relationships.contents.data.map(
(subItem: RecommendationGroupItem) => {
const subId = `${item.id}-${subItem.id}`;
switch (subItem.type) {
case 'playlists':
return (
<PlaylistItem key={subId} playlist={subItem} size={100} />
);
case 'albums':
return <AlbumItem key={subId} album={subItem} size={100} />;
default:
return null;
}
},
)}
</div>
</div>
);
Expand All @@ -194,10 +215,10 @@ class ForYouPage extends React.Component {
);
}

return recommendations.map(group => renderGroup(group));
return recommendations.map((group: RecommendationGroup) => renderGroup(group));
};

render() {
public render() {
const recentlyPlayed = this.renderRecentlyPlayed();
const heavyRotation = this.renderHeavyRotation();
const recommendations = this.renderRecommendations();
Expand Down