Skip to content

Commit

Permalink
Merge pull request #1019 from nataliauvarova/staging
Browse files Browse the repository at this point in the history
#971: fix for react 18
  • Loading branch information
nataliauvarova authored Aug 25, 2023
2 parents 82d0c27 + 78cbe77 commit c962a11
Showing 1 changed file with 40 additions and 37 deletions.
77 changes: 40 additions & 37 deletions src/pages/Perspective/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ const verbLanguagesDataQuery = gql`
const prepareLanguage = async (client, baseLanguage) => {
/* Getting all perspectives of the base language with verb data, including recursively perspectives of
* sub-languages. */

const {
data: {
language_tree: { tree: languageTree, languages }
Expand Down Expand Up @@ -341,41 +340,9 @@ const prepareLanguage = async (client, baseLanguage) => {
f(languageTree, baseLanguage.treePath.slice(0, -1));
};

/* Loads base language/corpora selection data for verb valency cases analysis. */
const getVerbSelectionData = async (perspectiveId, client, handler) => {
const {
data: { perspective }
} = await client.query({
query: verbPerpsectiveDataQuery,
variables: { perspectiveId }
});

/* Starting by finding the root language of the language group we are to analyze verb valency cases. */

const tree = perspective.tree;

const baseLanguage = {
...tree[tree.length - 1],
treePath: tree.slice(tree.length - 1, tree.length).reverse()
};

for (let i = 0; i < tree.length; i++) {
if (tree[i].in_toc) {
Object.assign(baseLanguage, tree[i]);
baseLanguage.treePath = tree.slice(i, tree.length).reverse();
break;
}
}

baseLanguage.treePathStr = baseLanguage.treePath.map(e => T(e.translations)).join(" \u203a ");

await prepareLanguage(client, baseLanguage);

handler(baseLanguage, baseLanguage.perspectiveList.length);
};

/* Loads language data for verb valency cases analysis. */
const getVerbSelectionLanguageData = async (client, initialLanguage, handler) => {

const {
data: { languages }
} = await client.query({
Expand Down Expand Up @@ -559,7 +526,42 @@ const VerbCasesContent = ({ perspectiveId, close, client, info }) => {
const [availableLanguageList, setAvailableLanguageList] = useState(undefined);

useEffect(
() =>
() => {

/* Loads base language/corpora selection data for verb valency cases analysis. */
const getVerbSelectionData = async (perspectiveId, client, handler) => {

const {
data: { perspective }
} = await client.query({
query: verbPerpsectiveDataQuery,
variables: { perspectiveId }
});

/* Starting by finding the root language of the language group we are to analyze verb valency cases.*/

const tree = perspective.tree;

const baseLanguage = {
...tree[tree.length - 1],
treePath: tree.slice(tree.length - 1, tree.length).reverse()
};

for (let i = 0; i < tree.length; i++) {
if (tree[i].in_toc) {
Object.assign(baseLanguage, tree[i]);
baseLanguage.treePath = tree.slice(i, tree.length).reverse();
break;
}
}

baseLanguage.treePathStr = baseLanguage.treePath.map(e => T(e.translations)).join(" \u203a ");

await prepareLanguage(client, baseLanguage);

handler(baseLanguage, baseLanguage.perspectiveList.length);
};

getVerbSelectionData(perspectiveId, client, (initialLanguage, selectedCount) => {
/* Finishing first phase of initialization, with the base language. */

Expand All @@ -579,11 +581,12 @@ const VerbCasesContent = ({ perspectiveId, close, client, info }) => {

getVerbSelectionLanguageData(client, initialLanguage, (baseLanguageList, baseLanguageMap) => {
/* Finishing second phase of initialization, got list of languages to select. */

setAvailableLanguageList(baseLanguageList);
info.baseLanguageMap = baseLanguageMap;
});
}),
});
},
[perspectiveId, client, info]
);

Expand Down

0 comments on commit c962a11

Please sign in to comment.