Skip to content

Commit

Permalink
fix: fix a few misc unused imports and useless assignments/conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
sct committed Dec 8, 2020
1 parent 5205ece commit 8e6daf7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/MovieDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ const MovieDetails: React.FC<MovieDetailsProps> = ({ movie }) => {
</div>
<Slider
sliderKey="cast"
isLoading={!data && !error}
isLoading={false}
isEmpty={false}
items={data?.credits.cast.slice(0, 20).map((person) => (
<PersonCard
Expand Down
2 changes: 1 addition & 1 deletion src/components/TvDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
</div>
<Slider
sliderKey="cast"
isLoading={!data && !error}
isLoading={false}
isEmpty={false}
items={data?.credits.cast.slice(0, 20).map((person) => (
<PersonCard
Expand Down
9 changes: 4 additions & 5 deletions src/context/UserContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { User, useUser } from '../hooks/useUser';
import { useRouter } from 'next/dist/client/router';

Expand All @@ -17,20 +17,19 @@ export const UserContext: React.FC<UserContextProps> = ({
}) => {
const { user, error, revalidate } = useUser({ initialData: initialUser });
const router = useRouter();
const routing = useRef(false);

useEffect(() => {
revalidate();
}, [router.pathname, revalidate]);

useEffect(() => {
let routing = false;

if (
!router.pathname.match(/(setup|login)/) &&
(!user || error) &&
!routing
!routing.current
) {
routing = true;
routing.current = true;
location.href = '/login';
}
}, [router, user, error]);
Expand Down
4 changes: 1 addition & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ CoreApp.getInitialProps = async (initialProps) => {

if (ctx.res) {
// Check if app is initialized and redirect if necessary
let initialized = true;

const response = await axios.get<{ initialized: boolean }>(
`http://localhost:${process.env.PORT || 3000}/api/v1/settings/public`
);

initialized = response.data.initialized;
const initialized = response.data.initialized;

if (!initialized) {
if (!router.pathname.match(/(setup|login\/plex)/)) {
Expand Down

0 comments on commit 8e6daf7

Please sign in to comment.