Skip to content

Commit

Permalink
auto check and mark done
Browse files Browse the repository at this point in the history
  • Loading branch information
sijumoncy committed Jul 9, 2024
1 parent 5db0a77 commit 527ac23
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
const handleFinishedBookResolution = async () => {
const resolvedBooks = { ...usfmJsons };
delete resolvedBooks.conflictMeta;

console.log('handle finish book resolution ===> ', resolvedBooks);
// work on single book
const resolvedMergeJson = resolvedBooks[selectedBook]?.mergeJson;
const generatedUSFM = await parseJsonToUsfm(resolvedMergeJson);
Expand Down Expand Up @@ -213,9 +213,12 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
setChapterResolveDone(false);
// remove current chapter from conflicted list
const restOfTheChapters = conflictedChapters[selectedBook]?.filter((chNo) => chNo !== selectedChapter);
setConflictedChapters((prev) => ({ ...prev, [selectedBook]: restOfTheChapters }));
setConflictedChapters((prev) => ({ ...prev, [selectedBook]: restOfTheChapters || [] }));
let isBookResolved = false;
if (restOfTheChapters?.length === 0) {
if (!restOfTheChapters) {
setResolvedBooks((prev) => [...prev, selectedBook]);
// isBookResolved = true;
} else if (restOfTheChapters?.length === 0) {
// completed conflicts for that particualr book
flushSync(() => {
setLoading(true);
Expand Down Expand Up @@ -262,7 +265,7 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
setError('Imported Usfm is invalid');
} else {
// Parse current project same book
const importedBookCode = `${importedJson.data.book.bookCode.toLowerCase()}.usfm`;
// const importedBookCode = `${importedJson.data.book.bookCode.toLowerCase()}.usfm`;

setError('');

Expand All @@ -285,7 +288,7 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
currentJson && currentJson?.valid && setUsfmJsons((prev) => ({ ...prev, [selectedBook]: { ...prev[selectedBook], current: currentJson.data, mergeJson } }));
// if processOutArr leng = 0 ; there is not actual conflict on content. so do auto resolve for the book
if (conflcitedChapters?.length > 0) {
setConflictedChapters((prev) => ({ ...prev, [selectedBook]: processOutArr[1] }));
setConflictedChapters((prev) => ({ ...prev, [selectedBook]: processOutArr[1] || [] }));
if (conflcitedChapters && conflcitedChapters?.length > 0) {
setSelectedChapter(conflcitedChapters[0]);
}
Expand All @@ -312,7 +315,6 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
if (fs.existsSync(path.join(data.projectMergePath, 'usfmJsons.json'))) {
let usfmJsonsContent = fs.readFileSync(path.join(data.projectMergePath, 'usfmJsons.json'), 'utf8');
usfmJsonsContent = JSON.parse(usfmJsonsContent);
console.log({ usfmJsonsContent });
if (usfmJsonsContent) {
setUsfmJsons(usfmJsonsContent);
// check the books is already resolved or not => then select current book and unresolved chapters
Expand All @@ -332,7 +334,7 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
if (currentBook.isBookResolved) {
resolvedBooksArr.push(book);
}
conflictedChsOfBooks[book] = currentBook.conflictedChapters;
conflictedChsOfBooks[book] = currentBook.conflictedChapters || [];
}
}

Expand Down Expand Up @@ -437,7 +439,7 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
// if (!loading && usfmJsons?.conflictMeta && selectedBook) {
(async () => {
setLoading(true);
if (conflictedChapters[selectedBook]) {
if (conflictedChapters[selectedBook]?.length > 0) {
// Auto Select first Chapter of the selected Book
if (conflictedChapters[selectedBook] && conflictedChapters[selectedBook].length > 0) {
setSelectedChapter(conflictedChapters[selectedBook][0]);
Expand Down

0 comments on commit 527ac23

Please sign in to comment.