Skip to content

Commit

Permalink
Merge pull request #191 from QUACK-INTEC/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
jtvargas authored Mar 8, 2020
2 parents 7e7bdaf + 2bb601e commit bab83c4
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 20 deletions.
4 changes: 2 additions & 2 deletions App/Components/ClassHub/ClassHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class ClassHub extends React.PureComponent {
};

renderPostsEmpty = () => {
const { isFetchingPost, isLoadingPosts } = this.props;
const { isLoadingPosts } = this.props;

if (isLoadingPosts || isFetchingPost) {
if (isLoadingPosts) {
return (
<View style={styles.centerEmptyContainer}>
<LoadingState.Small />
Expand Down
5 changes: 4 additions & 1 deletion App/Components/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import Moment from 'moment/min/moment-with-locales';
import Lodash from 'lodash';

import { colors, spacers, fonts, toBaseDesignPx } from '../../Core/Theme';
import { colors, spacers, fonts, toBaseDesignPx, constants } from '../../Core/Theme';
import Text from '../Common/Text';
import InLineComponent from '../Common/InLineComponent';
import Section from '../Common/Section';
Expand Down Expand Up @@ -126,6 +126,9 @@ class Home extends React.Component {
const { events, subjects, onMyCalendarPress, isLoading } = this.props;

if (isLoading) {
if (constants.isAndroid) {
return <LoadingState.Small />;
}
return (
<LoadingList
renderItem={this.renderEventCalendarLoadingState}
Expand Down
12 changes: 12 additions & 0 deletions App/Navigation/MainTabNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ const ProfileStack = createStackNavigator(
ChangePassword: {
screen: ChangePasswordScreen,
},

ClassHub: {
screen: ClassHubScreen,
},
PostInfo,
Participants: ClassParticipantsScreen,
ViewProfile: ViewProfileScreen,
SubjectsByTeacher: SubjectsByTeacherScreen,
TeacherResources: TeacherResourcesScreen,
PostComments: PostCommentsScreen,
PostResources: PostResourcesScreen,
ViewResource: ViewResourceScreen,
},
config
);
Expand Down
7 changes: 1 addition & 6 deletions App/Screens/ClassHub/ClassHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,4 @@ const mapDispatchToProps = dispatch => {
);
};

export default WithLogger(
connect(
mapStateToProps,
mapDispatchToProps
)(ClassHub)
);
export default WithLogger(connect(mapStateToProps, mapDispatchToProps)(ClassHub));
10 changes: 7 additions & 3 deletions App/Screens/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Lodash from 'lodash';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PropTypes from 'prop-types';
import { withNavigationFocus } from 'react-navigation';

import LoadingState from '../../Components/LoadingState';
import HomeComponent from '../../Components/Home';
Expand Down Expand Up @@ -52,8 +53,11 @@ class Home extends React.Component {
}

componentDidUpdate(prevProps) {
const { isModalVisible } = this.props;
if (prevProps.isModalVisible !== isModalVisible) {
const { isModalVisible, isFocused } = this.props;
if (
prevProps.isModalVisible !== isModalVisible ||
(prevProps.isFocused !== isFocused && isFocused)
) {
return this.fetchEventsAndClasses();
}
return false;
Expand Down Expand Up @@ -397,4 +401,4 @@ const mapDispatchToProps = dispatch => {
);
};

export default WithLogger(connect(mapStateToProps, mapDispatchToProps)(Home));
export default withNavigationFocus(WithLogger(connect(mapStateToProps, mapDispatchToProps)(Home)));
7 changes: 3 additions & 4 deletions App/Screens/PostComments/PostComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ class PostComments extends React.Component {
return this.setState({ isLoading });
};

handleAuthorPress = () => {
handleAuthorPress = authorId => {
const {
navigation: { navigate },
} = this.props;
const { authorId } = this.state;
return navigate('ViewProfile', { userId: authorId });
};

Expand Down Expand Up @@ -90,7 +89,7 @@ class PostComments extends React.Component {
this.setState({ isLoading: false });
const isSuccess = Lodash.get(objResponse, ['data', 'success'], false);
if (isSuccess) {
current.setToastVisible(GAMIFICATION_MSG(1));
current.setToastVisible(GAMIFICATION_MSG(5));
const modifiedCommentObj = { ...commentObj };
modifiedCommentObj.score =
commentObj.currentUserReaction !== 0 ? commentObj.score + 2 : commentObj.score + 1;
Expand Down Expand Up @@ -183,7 +182,7 @@ class PostComments extends React.Component {
this.setState({ isLoading: false });
const isSuccess = Lodash.get(objResponse, ['data', 'success'], false);
if (isSuccess) {
current.setToastVisible(GAMIFICATION_MSG(1));
current.setToastVisible(GAMIFICATION_MSG(5));
const modifiedCommentObj = { ...commentObj };
modifiedCommentObj.score =
commentObj.currentUserReaction !== 0 ? commentObj.score - 2 : commentObj.score - 1;
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/PostInfo/PostInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class PostInfo extends React.Component {
this.setState({ isLoading: false });
const isSuccess = Lodash.get(objResponse, ['data', 'success'], false);
if (isSuccess) {
current.setToastVisible(GAMIFICATION_MSG(10));
current.setToastVisible(GAMIFICATION_MSG(5));
this.setState(prevState => ({
isLoading: false,
score:
Expand Down Expand Up @@ -441,7 +441,7 @@ class PostInfo extends React.Component {
this.setState({ isLoading: false });
const isSuccess = Lodash.get(objResponse, ['data', 'success'], false);
if (isSuccess) {
current.setToastVisible(GAMIFICATION_MSG(10));
current.setToastVisible(GAMIFICATION_MSG(5));
this.setState(prevState => ({
isLoading: false,
score:
Expand Down
1 change: 1 addition & 0 deletions App/Screens/SyncAccount/SyncAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class SyncAccount extends Component {

const userToken = getParam('userToken', null);

console.log({ objUserSyncData });
if (objUserSyncData) {
setUserSync(objUserSyncData);
if (userToken) {
Expand Down
4 changes: 2 additions & 2 deletions App/Utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-undef */
/* eslint-disable import/prefer-default-export */
import * as mime from 'react-native-mime-types';
import { Platform } from 'react-native';

export const toUpperCaseFirsLetter = str => {
Expand All @@ -13,10 +14,9 @@ export const toUpperCaseFirsLetter = str => {

export const createFormDataPhoto = photo => {
const data = new FormData();

data.append('file', {
name: 'file',
type: 'image/jpg',
type: mime.lookup(photo),
uri: Platform.OS === 'android' ? photo : photo.replace('file://', ''),
});

Expand Down

0 comments on commit bab83c4

Please sign in to comment.