Skip to content

Commit

Permalink
Adapted sg_count and sg_state_list
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Feb 20, 2025
1 parent dd568e5 commit 7b93954
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/components/CognateAnalysisModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2158,18 +2158,29 @@ class CognateAnalysisModal extends React.Component {
sg_count: sg_count_cur,
sg_entry_map: sg_entry_map_cur })
{
const sg_select_list = sg_select_list_cur ?? [];
const sg_state_list = sg_state_list_cur ?? [];

const sg_count = sg_count_cur ?? {
const sg_count_init = {
left: 0,
connecting: 0,
connected: 0,
error: 0,
invalidated: 0
};

const sg_entry_map = sg_entry_map_cur ?? {};
// Clean connecting states if is
const sg_count = { ...(sg_count_cur ?? sg_count_init), connecting: 0 };
sg_count.left = (
suggestion_list.length -
sg_count.connected -
sg_count.error -
sg_count.invalidated
);

const sg_state_list = (sg_state_list_cur ?? []).map(elem => (elem === "connecting") ? "left" : elem);

// Deep clone because of immutability
const sg_entry_map = cloneDeep(sg_entry_map_cur ?? {});
const sg_select_list = cloneDeep(sg_select_list_cur ?? []);

/* Initializing suggestions data, if required. */
if (suggestion_list) {
Expand Down Expand Up @@ -2203,8 +2214,6 @@ class CognateAnalysisModal extends React.Component {
sg_select_list.push(sg_select_item);
sg_state_list.push("left");
}

sg_count.left += suggestion_list.length;
}

return {
Expand Down

0 comments on commit 7b93954

Please sign in to comment.