Skip to content

Commit

Permalink
correct rerendering
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Nov 15, 2024
1 parent 1d73730 commit d22019d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/components/UploadModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from "prop-types";
import { branch, compose, onlyUpdateForKeys, renderNothing, withProps } from "recompose";
import { bindActionCreators } from "redux";

import { closeUploadModal } from "ducks/upload";
import { closeUploadModal, updateUploadModal } from "ducks/upload";
import TranslationContext from "Layout/TranslationContext";

const getUploadDate = gql`
Expand All @@ -33,9 +33,8 @@ const uploadPerspective = gql`

const Upload = props => {

const [uploading, setUploading] = useState(props.uploading); // uploading value goes from the parent component
const getTranslation = useContext(TranslationContext);
const { id, title, data, actions, user, uploadPerspective } = props;
const { id, title, data, actions, user, uploading, uploadPerspective } = props;
const { loading, error, refetch, perspective } = data;

if (loading) {
Expand Down Expand Up @@ -90,8 +89,8 @@ const Upload = props => {
getTranslation(uploaded_at ? "Refresh" : "Upload")
)}
onClick={() => {
setUploading(true);
uploadPerspective(title);
actions.updateUploadModal(true);
uploadPerspective();
}}
disabled={uploading}
className="lingvo-button-greenest"
Expand Down Expand Up @@ -128,7 +127,8 @@ Upload.propTypes = {
loading: PropTypes.bool.isRequired
}).isRequired,
actions: PropTypes.shape({
closeUploadModal: PropTypes.func.isRequired
closeUploadModal: PropTypes.func.isRequired,
updateUploadModal: PropTypes.func.isRequired
}).isRequired
};

Expand All @@ -138,11 +138,11 @@ export default compose(
),
connect(
state => state.upload,
dispatch => ({ actions: bindActionCreators({ closeUploadModal }, dispatch) })
dispatch => ({ actions: bindActionCreators({ closeUploadModal, updateUploadModal }, dispatch) })
),
branch(({ upload }) => !upload, renderNothing),
withProps(({ upload: { id, title, uploading, uploadPerspective } }) => ({ id, title, uploading, uploadPerspective })),
graphql(getUploadDate, { options: { fetchPolicy: "network-only" }}),
//graphql(uploadPerspective, { name: "uploadPerspective" }),
onlyUpdateForKeys(["upload", "uploading", "data"])
onlyUpdateForKeys(["upload", "data"])
)(Upload);
2 changes: 1 addition & 1 deletion src/pages/Perspective/PerspectivePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PerspectivePath extends React.Component {
this.uploadPerspectiveWrapper = this.uploadPerspectiveWrapper.bind(this);
};

uploadPerspectiveWrapper(title) {
uploadPerspectiveWrapper() {
const {id, actions, uploadPerspective} = this.props;

this.setState({ uploading: true });
Expand Down

0 comments on commit d22019d

Please sign in to comment.