refactoring: first render improvements
This commit is contained in:
1 parent
38aebcbe28
commit
0cface89bf
13 files changed
+38
-33
No files matched your search
+2
-2
@@ -8,7 +8,7 @@ export const mapMovieSeriesToShow = (
|
||||
rating: vote_average,
|
||||
votes: vote_count,
|
||||
backdrop: backdrop_path ? `https://image.tmdb.org/t/p/w1280/${backdrop_path}` : '',
|
||||
poster: poster_path ? `https://image.tmdb.org/t/p/w500/${poster_path}` : '',
|
||||
poster: poster_path ? `https://image.tmdb.org/t/p/w342/${poster_path}` : '',
|
||||
release: 'release_date' in item ? item.release_date : item.first_air_date,
|
||||
title: 'release_date' in item ? item.title : item.name
|
||||
});
|
||||
@@ -20,7 +20,7 @@ const mapMoviesSeriesResponseToShows = (
|
||||
page,
|
||||
total: total_pages,
|
||||
results: results
|
||||
.map(show => mapMovieSeriesToShow(show, type))
|
||||
.map((show) => mapMovieSeriesToShow(show, type))
|
||||
.filter((show) => show.votes && show.release && show.backdrop && show.poster)
|
||||
});
|
||||
|
||||
|
||||
+7
-5
@@ -10,6 +10,8 @@ import yts from './parsers/yts';
|
||||
import http from './Http';
|
||||
import { Sort } from './parsers';
|
||||
|
||||
const session = () => cookies().get('session')?.value;
|
||||
|
||||
export const createRequestToken = async () => {
|
||||
return http.get<RequestToken>('/authentication/token/new', { preventCache: true }).then(({ request_token }) => ({
|
||||
redirectUrl: `https://www.themoviedb.org/authenticate/${request_token}`,
|
||||
@@ -26,14 +28,14 @@ export const createSession = async ({ requestToken }: { requestToken: string })
|
||||
|
||||
export const account = async () => {
|
||||
return http.get<Account>('/account/null', {
|
||||
params: { session_id: cookies().get('session')?.value },
|
||||
params: { session_id: session() },
|
||||
preventCache: true
|
||||
});
|
||||
};
|
||||
|
||||
export const accountStates = async ({ showId, showType }: { showId: Show['id']; showType: Show['type'] }) => {
|
||||
return http.get<ShowState>(`/${showType}/${showId}/account_states`, {
|
||||
params: { session_id: cookies().get('session')?.value },
|
||||
params: { session_id: session() },
|
||||
preventCache: true
|
||||
});
|
||||
};
|
||||
@@ -51,7 +53,7 @@ export const updateAccountStates = async ({
|
||||
}) => {
|
||||
http.post(
|
||||
`/account/null/${list}`,
|
||||
{ params: { session_id: cookies().get('session')?.value }, preventCache: true },
|
||||
{ params: { session_id: session() }, preventCache: true },
|
||||
{
|
||||
media_id: showId,
|
||||
media_type: showType,
|
||||
@@ -71,7 +73,7 @@ export const usersShows = async ({
|
||||
}): Promise<Pagination<Show>> => {
|
||||
return http
|
||||
.get<TMDBPagination<Movie>>(`/account/null/${list}/${showType === 'tv' ? 'tv' : 'movies'}`, {
|
||||
params: { page, sort_by: 'created_at.desc', session_id: cookies().get('session')?.value },
|
||||
params: { page, sort_by: 'created_at.desc', session_id: session() },
|
||||
preventCache: true
|
||||
})
|
||||
.then((response) => mapMoviesSeriesResponseToShows(response, showType));
|
||||
@@ -224,7 +226,7 @@ export const credits = async ({
|
||||
return cast
|
||||
.filter((person) => person.profile_path)
|
||||
.map((actor) => {
|
||||
const photoUrl = `https://image.tmdb.org/t/p/w500/${actor.profile_path}`;
|
||||
const photoUrl = `https://image.tmdb.org/t/p/w185${actor.profile_path}`;
|
||||
|
||||
if ('character' in actor) return { ...actor, photoUrl };
|
||||
|
||||
|
||||
Reference in new issue
Block a user