Skip to content

Commit

Permalink
Correct killing
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Feb 15, 2025
1 parent 750efe1 commit b5de2af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
29 changes: 0 additions & 29 deletions src/components/CognateAnalysisModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,6 @@ const computeNeuroCognateAnalysisMutation = gql`
}
`;

const stopNeuroCognateAnalysisMutation = gql`
mutation stopNeuroCognateAnalysis (
$stamp: Float!
) {
stop_mutation(
stamp: $stamp
) {
triumph
}
}
`;

const computeComplexDistanceMutation = gql`
mutation complexDistance (
$resultPool: [ObjectVal]!
Expand Down Expand Up @@ -1445,7 +1433,6 @@ class CognateAnalysisModal extends React.Component {

this.suggestions_render = this.suggestions_render.bind(this);
this.browse_files_render = this.browse_files_render.bind(this);
this.stopMutation = this.stopMutation.bind(this);
this.getResultData = this.getResultData.bind(this);

this.sg_connect = this.sg_connect.bind(this);
Expand Down Expand Up @@ -3161,18 +3148,6 @@ class CognateAnalysisModal extends React.Component {
)
}

stopMutation() {
const { computing } = this.state;

if (typeof computing !== "boolean") {
this.props.stopNeuroCognateAnalysis({
variables: {
stamp: computing
}
});
}
}

async getResultData() {
const {
data: {
Expand Down Expand Up @@ -3258,7 +3233,6 @@ class CognateAnalysisModal extends React.Component {
closeIcon
onClose={ () => {
this.setState({ computing: false }, this.props.closeModal);
this.stopMutation();
}}
dimmer open
size="fullscreen" className="lingvo-modal2">
Expand Down Expand Up @@ -3304,7 +3278,6 @@ class CognateAnalysisModal extends React.Component {
content={this.context("Stop")}
onClick={() => {
this.setState({ computing: false });
this.stopMutation();
}}
className="lingvo-button-red"
/>
Expand All @@ -3327,7 +3300,6 @@ class CognateAnalysisModal extends React.Component {
content={this.context("Close")}
onClick={ () => {
this.setState({ computing: false }, this.props.closeModal);
this.stopMutation();
}}
className="lingvo-button-basic-black"
/>
Expand Down Expand Up @@ -3658,6 +3630,5 @@ export default compose(
graphql(computeComplexDistanceMutation, { name: "computeComplexDistance" }),
graphql(computeNeuroCognateAnalysisMutation, { name: "computeNeuroCognateAnalysis" }),
graphql(connectMutation, { name: "connectGroup" }),
graphql(stopNeuroCognateAnalysisMutation, { name: "stopNeuroCognateAnalysis" }),
withApollo
)(CognateAnalysisModal);
39 changes: 33 additions & 6 deletions src/components/TaskList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Button, List, Progress } from "semantic-ui-react";
import PropTypes from "prop-types";
import { branch, compose, lifecycle, renderComponent } from "recompose";
import { bindActionCreators } from "redux";
import { graphql } from "@apollo/client/react/hoc";
import { gql } from "@apollo/client";

import { run, stop } from "ducks/saga";
import { removeTask } from "ducks/task";
Expand All @@ -13,6 +15,18 @@ import imageEmpty from "../../images/no_data.svg";

import saga from "./saga";

const stopNeuroCognateAnalysisMutation = gql`
mutation stopNeuroCognateAnalysis (
$stamp: String!
) {
stop_mutation(
stamp: $stamp
) {
triumph
}
}
`;

const Empty = () => {
const getTranslation = useContext(TranslationContext);

Expand All @@ -36,7 +50,8 @@ function Task(props) {
current_stage,
total_stages,
result_link_list,
removeTask: remove
removeTask: remove,
stopNeuroCognateAnalysis
} = props;

const links = result_link_list.map(link => (
Expand All @@ -51,7 +66,17 @@ function Task(props) {
<List.Content>
<div className="lingvo-task">
<div className="lingvo-task__title">{task_family}</div>
<Button className="lingvo-task__delete" onClick={() => remove(id)}>
<Button
className="lingvo-task__delete"
onClick={() => {
stopNeuroCognateAnalysis({
variables: {
stamp: id
}
});
remove(id);
}}
>
<i className="lingvo-icon-close" />
</Button>
<div className="lingvo-task__content">
Expand Down Expand Up @@ -84,18 +109,19 @@ function Task(props) {

const Task1 = connect(null, dispatch => bindActionCreators({ removeTask }, dispatch))(Task);

const TaskList = enhance(({ tasks }) => (
const TaskList = enhance(({ tasks, stopNeuroCognateAnalysis }) => (
<List relaxed>
{tasks.map(task => (
<List.Item key={task.id}>
<Task1 {...task} />
<Task1 {...task} stopNeuroCognateAnalysis={stopNeuroCognateAnalysis} />
</List.Item>
))}
</List>
));

TaskList.propTypes = {
tasks: PropTypes.array.isRequired
tasks: PropTypes.array.isRequired,
stopNeuroCognateAnalysis: PropTypes.func.isRequired
};

function generateId() {
Expand Down Expand Up @@ -124,5 +150,6 @@ export default compose(
componentWillUnmount() {
this.props.onUnmount();
}
})
}),
graphql(stopNeuroCognateAnalysisMutation, { name: "stopNeuroCognateAnalysis" })
)(TaskList);

0 comments on commit b5de2af

Please sign in to comment.