Skip to content

Commit

Permalink
Move set top header visibility logic to task action page
Browse files Browse the repository at this point in the history
Moves the actions dispatches to the `TaskAction` component, removing it from both the `Editor` and the `RapidEditor` components.
  • Loading branch information
HelNershingThapa committed Jul 6, 2023
1 parent 1d63c23 commit 6fa841f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
8 changes: 0 additions & 8 deletions frontend/src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,8 @@ export default function Editor({ setDisable, comment, presets, imagery, gpxUrl }
}
}, [customImageryIsSet, imagery, iDContext, customSource]);

useEffect(() => {
return () => {
dispatch({ type: 'SET_VISIBILITY', isVisible: true });
};
// eslint-disable-next-line
}, []);

useEffect(() => {
if (windowInit) {
dispatch({ type: 'SET_VISIBILITY', isVisible: false });
if (iDContext === null) {
// we need to keep iD context on redux store because iD works better if
// the context is not restarted while running in the same browser session
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/components/rapidEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,8 @@ export default function RapidEditor({
}
}, [customImageryIsSet, imagery, RapiDContext, customSource]);

useEffect(() => {
return () => {
dispatch({ type: 'SET_VISIBILITY', isVisible: true });
};
// eslint-disable-next-line
}, []);

useEffect(() => {
if (windowInit) {
dispatch({ type: 'SET_VISIBILITY', isVisible: false });
if (RapiDContext === null) {
// we need to keep iD context on redux store because iD works better if
// the context is not restarted while running in the same browser session
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/views/taskAction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate, useParams } from 'react-router-dom';
import { useQueryParam, StringParam } from 'use-query-params';
import { FormattedMessage } from 'react-intl';
Expand All @@ -25,6 +25,7 @@ export function ValidateTask() {

export function TaskAction({ project, action }: Object) {
const navigate = useNavigate();
const dispatch = useDispatch();
const userDetails = useSelector((state) => state.auth.userDetails);
const token = useSelector((state) => state.auth.token);
const locale = useSelector((state) => state.preferences.locale);
Expand All @@ -33,14 +34,12 @@ export function TaskAction({ project, action }: Object) {
const [tasks, setTasks] = useState([]);
const [loading, setLoading] = useState(true);

const getTasks = () => {
fetchLocalJSONAPI(`users/queries/tasks/locked/details/`, token, 'GET', locale)
.then((res) => {
setTasks(res.tasks);
setLoading(false);
})
.catch((e) => navigate(`/projects/${project}/tasks/`));
};
useEffect(() => {
dispatch({ type: 'SET_VISIBILITY', isVisible: false });
return () => {
dispatch({ type: 'SET_VISIBILITY', isVisible: true });
};
}, [dispatch]);

useEffect(() => {
if (userDetails.id && token && action && project) {
Expand Down

0 comments on commit 6fa841f

Please sign in to comment.