Skip to content

Commit

Permalink
fixed navigation for tn and tq
Browse files Browse the repository at this point in the history
  • Loading branch information
sijumoncy committed Nov 24, 2023
1 parent 534cb33 commit e66b4e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
17 changes: 15 additions & 2 deletions renderer/src/components/EditorPage/Reference/ReferenceCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { CardContent, useCardState } from 'translation-helps-rcl';
import TranslationhelpsNav from './TranslationhelpsNav';
Expand All @@ -13,6 +13,8 @@ const ReferenceCard = ({
viewMode,
isLoading,
font,
setResetTrigger,
resetTrigger,
}) => {
const {
state: {
Expand All @@ -22,16 +24,27 @@ const ReferenceCard = ({
setItemIndex,
},
} = useCardState({ items });
console.log({ item });
console.log({ item, itemIndex });

Check warning on line 27 in renderer/src/components/EditorPage/Reference/ReferenceCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 27 in renderer/src/components/EditorPage/Reference/ReferenceCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
console.log('testing');

Check warning on line 28 in renderer/src/components/EditorPage/Reference/ReferenceCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 28 in renderer/src/components/EditorPage/Reference/ReferenceCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

useEffect(() => {
if (resetTrigger) {
setItemIndex(0);
setResetTrigger(false);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [resetTrigger]);

return (
<>
{item && items.length > 0 && (
<TranslationhelpsNav
classes
items={items}
itemIndex={itemIndex}
setItemIndex={setItemIndex}
/>
)}
<div style={{ fontFamily: font || 'sans-serif' }}>
<CardContent
item={item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import {
useContent,
// useCardState,
// CardContent,
// CardContent,
} from 'translation-helps-rcl';
import localForage from 'localforage';
import ReferenceCard from './ReferenceCard';
Expand Down Expand Up @@ -31,6 +31,7 @@ export default function TranslationHelpsCard({
const [offlineItems, setOfflineItems] = useState([]);
const [offlineItemsDisable, setOfflineItemsDisable] = useState(false);
const [offlineMarkdown, setOfflineMarkdown] = useState('');
const [resetTrigger, setResetTrigger] = useState(false);

// eslint-disable-next-line prefer-const
let { items, markdown, isLoading } = useContent({
Expand Down Expand Up @@ -61,27 +62,27 @@ export default function TranslationHelpsCard({
const currentUser = user?.username;
const folder = path.join(newpath, packageInfo.name, 'users', `${currentUser}`, 'resources');
const projectName = `${offlineResource?.data?.value?.meta?.name}_${offlineResource?.data?.value?.meta?.owner}_${offlineResource?.data?.value?.meta?.release?.tag_name}`;
// const projectName = 'en_tn_unfoldingWord_v77 (copy)';
// const projectName = 'en_tn_unfoldingWord_v77 (copy)';
console.log(resourceId);

Check warning on line 66 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 66 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
// switch resources
switch (resourceId) {
case 'tn':
console.log(path.join(folder, projectName), fs.existsSync(path.join(folder, projectName)));
console.log(path.join(folder, projectName), fs.existsSync(path.join(folder, projectName)));

Check warning on line 70 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 70 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
if (fs.existsSync(path.join(folder, projectName))) {
console.log('yes');
console.log('yes');

Check warning on line 72 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 72 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
// eslint-disable-next-line array-callback-return
const currentFile = offlineResource?.data?.value?.projects.filter((item) => {
console.log('item', item, projectId);
console.log('item', item, projectId);

Check warning on line 75 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 75 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
if (item?.identifier.toLowerCase() === projectId.toLowerCase()) {
return item;
}
});
console.log('project name content : ', currentFile[0].path);

Check warning on line 80 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 80 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
const filecontent = await fs.readFileSync(path.join(folder, projectName, currentFile[0].path), 'utf8');
console.log(filecontent);
console.log(filecontent);

Check warning on line 82 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 82 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
// convert tsv to json
const headerArr = filecontent.split('\n')[0].split('\t');
console.log(headerArr);
console.log(headerArr);

Check warning on line 85 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement

Check warning on line 85 in renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js

View workflow job for this annotation

GitHub Actions / Lint Run

Unexpected console statement
let noteName;
let indexOfNote;
if (headerArr.indexOf('Note') > 0) {
Expand Down Expand Up @@ -211,7 +212,8 @@ export default function TranslationHelpsCard({
}
}
// reset index
// eslint-disable-next-line react-hooks/exhaustive-deps
setResetTrigger(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [verse, chapter, languageId, resourceId, owner, offlineResource, projectId, items, filePath]);

items = !offlineItemsDisable && offlineResource?.offline ? offlineItems : items;
Expand All @@ -231,6 +233,8 @@ export default function TranslationHelpsCard({
selectedQuote={selectedQuote}
setQuote={setQuote}
font={font}
setResetTrigger={setResetTrigger}
resetTrigger={resetTrigger}
/>
);
}
Expand Down

0 comments on commit e66b4e4

Please sign in to comment.