+ const isMobile = window.innerWidth < 480;
+ if (!isMobile) {
+ return (
+
+
+
+
+

+
{show.title}
+
+
diff --git a/client/src/components/MediaList.js b/client/src/components/MediaList.js
index 7606540..39f17da 100644
--- a/client/src/components/MediaList.js
+++ b/client/src/components/MediaList.js
@@ -5,9 +5,10 @@ import {connect} from 'react-redux';
import styles from '../css/materialize.css.js';
import axios from 'axios';
import MediaCard from './MediaCard';
+import * as actions from '../actions';
class MediaList extends Component {
- state = {tvShowList: []};
+ state = {tvShowList: [], loading: false};
componentDidMount() {
this.getMostWatched();
@@ -18,6 +19,7 @@ class MediaList extends Component {
};
render() {
+ console.log('My state--', this.state);
const mediaList = this.state.tvShowList.map(show => {
return (
@@ -33,8 +35,12 @@ MediaList.propTypes = {
classes: PropTypes.object.isRequired,
};
-function mapStateToProps({auth}) {
- return {auth};
+function mapStateToProps({plex}) {
+ console.log('plex props', plex);
+ return {loading: plex.loading};
}
-export default connect(mapStateToProps)(withStyles(styles)(MediaList));
+export default connect(
+ mapStateToProps,
+ actions,
+)(withStyles(styles)(MediaList));
diff --git a/client/src/components/plex/PlexTokenForm.js b/client/src/components/plex/PlexTokenForm.js
index 9b9e14f..9b7e133 100644
--- a/client/src/components/plex/PlexTokenForm.js
+++ b/client/src/components/plex/PlexTokenForm.js
@@ -42,9 +42,9 @@ class PlexTokenForm extends React.Component {
-
+
-
+
diff --git a/client/src/css/materialize.css b/client/src/css/materialize.css
index d7799e4..34219e9 100644
--- a/client/src/css/materialize.css
+++ b/client/src/css/materialize.css
@@ -7,5 +7,17 @@
}
.padding-bottom-5 {
- padding-bottom: 5em
-}
\ No newline at end of file
+ padding-bottom: 5em;
+}
+
+.hide-mobile {
+ @media (max-width: 480px) {
+ display: none;
+ }
+}
+
+.hide-desktop {
+ @media not all and (max-width: 480px) {
+ display: none;
+ }
+}
diff --git a/client/src/reducers/authReducer.js b/client/src/reducers/authReducer.js
index 8d585ed..4e65b2c 100644
--- a/client/src/reducers/authReducer.js
+++ b/client/src/reducers/authReducer.js
@@ -1,9 +1,8 @@
-import {FETCH_USER} from '../actions/types';
+import {types} from '../actions/index';
export default function(state = {}, action) {
- console.log('auth-state', state);
switch (action.type) {
- case FETCH_USER:
+ case types.FETCH_USER:
return action.payload || false;
default:
return state;
diff --git a/client/src/reducers/plexReducer.js b/client/src/reducers/plexReducer.js
index 1363706..9c39eec 100644
--- a/client/src/reducers/plexReducer.js
+++ b/client/src/reducers/plexReducer.js
@@ -1,12 +1,20 @@
-import {FETCH_PLEX_TOKEN, FETCH_MEDIA} from '../actions/types';
+import {types} from '../actions/index';
-export default function(state = '', action) {
+export const initialState = {
+ loading: false,
+ plexToken: '',
+ mediaResponse: [],
+};
+export default function(state = initialState, action) {
console.log('Action!', action);
+ console.log('State!!', state);
switch (action.type) {
- case FETCH_PLEX_TOKEN:
- return action.payload || false;
- case FETCH_MEDIA:
- return action.payload || false;
+ case types.FETCH_PLEX_TOKEN:
+ return action.payload.plexToken || false;
+ case types.FETCH_MEDIA_RESPONSE:
+ return action.payload.mediaResponse || false;
+ case types.SET_LOADING:
+ return {...state, loading: action.payload};
default:
return state;
}
diff --git a/server/services/plex/index.js b/server/services/plex/index.js
index 063f592..4494921 100644
--- a/server/services/plex/index.js
+++ b/server/services/plex/index.js
@@ -73,12 +73,15 @@ const importMostWatched = async (req, res) => {
};
const importAll = async (req, res) => {
- await importData.importSections(req.user);
- await importData.importLibraries(req.user);
- await importData.importMostWatched(req.user);
- const images = await importData.importTvPosters(req.user);
-
- res.json(images);
+ try {
+ await importData.importSections(req.user);
+ await importData.importLibraries(req.user);
+ await importData.importMostWatched(req.user);
+ await importData.importTvPosters(req.user);
+ res.json('Successfully imported/updated data');
+ } catch (error) {
+ res.json(error);
+ }
};
export default {
diff --git a/server/services/recommend/index.js b/server/services/recommend/index.js
index a6e3f4b..1a2ce28 100644
--- a/server/services/recommend/index.js
+++ b/server/services/recommend/index.js
@@ -4,11 +4,9 @@ import {Op} from 'sequelize';
const getMostWatched = async (req, res) => {
try {
- console.log('mike');
const mostWatched = await models.PlexLibrary.findAll({
where: {UserId: req.user.id, type: 'show', views: {[Op.gt]: 0}},
});
- console.log('mostwatched', mostWatched);
res.json(mostWatched);
} catch (error) {
res.json(error.message);