Skip to content

Commit

Permalink
reset created entries on perspective opening
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Oct 17, 2024
1 parent a1e0f87 commit ddb4bcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/PerspectiveView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Placeholder from "components/Placeholder";
import { openModal } from "ducks/modals";
import {
addLexicalEntry,
resetAddedLexes,
resetEntriesSelection,
resetSortByField,
selectLexicalEntry,
Expand Down Expand Up @@ -269,6 +270,10 @@ class P extends React.Component {
//this.reRender = this.reRender.bind(this);
}

componentDidMount() {
this.props.resetAddedLexes();
}

componentDidUpdate(prevProps) {
const { data } = this.props;
if (!data.perspective) {
Expand Down Expand Up @@ -745,6 +750,7 @@ P.propTypes = {
setSortByField: PropTypes.func.isRequired,
resetSortByField: PropTypes.func.isRequired,
addLexicalEntry: PropTypes.func.isRequired,
resetAddedLexes: PropTypes.func.isRequired,
createLexicalEntry: PropTypes.func.isRequired,
mergeLexicalEntries: PropTypes.func.isRequired,
removeLexicalEntries: PropTypes.func.isRequired,
Expand Down Expand Up @@ -777,6 +783,7 @@ const PerspectiveView = compose(
bindActionCreators(
{
addLexicalEntry,
resetAddedLexes,
setSortByField,
resetSortByField,
selectLexicalEntry,
Expand Down
7 changes: 7 additions & 0 deletions src/ducks/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const RESET_SORT_MODE = "@data/perspective/RESET_SORT_MODE";
export const SET_ORDERED_SORT_MODE = "@data/perspective/SET_ORDERED_SORT_MODE";
export const RESET_ORDERED_SORT_MODE = "@data/perspective/RESET_ORDERED_SORT_MODE";
export const ADD_LEXICAL_ENTRY = "@data/perspective/ADD_LEXICAL_ENTRY";
export const RESET_ADDED_LEXES = "@data/perspective/RESET_ADDED_LEXES";
export const SELECT_LEXICAL_ENTRY = "@data/perspective/SELECT_LEXICAL_ENTRY";
export const RESET_ENTRIES_SELECTION = "@data/perspective/RESET_ENTRIES_SELECTION";

Expand Down Expand Up @@ -58,6 +59,8 @@ function createdEntries(state = [], { type, payload }) {
switch (type) {
case ADD_LEXICAL_ENTRY:
return [payload, ...state];
case RESET_ADDED_LEXES:
return [];
default:
return state;
}
Expand Down Expand Up @@ -123,6 +126,10 @@ export function addLexicalEntry(entry) {
return { type: ADD_LEXICAL_ENTRY, payload: entry };
}

export function resetAddedLexes(entry) {
return { type: RESET_ADDED_LEXES, payload: null };
}

export function selectLexicalEntry(id, checked) {
return { type: SELECT_LEXICAL_ENTRY, payload: { id, checked } };
}
Expand Down

0 comments on commit ddb4bcd

Please sign in to comment.