Skip to content

Commit

Permalink
added conflict detection based on the current and incoming content va…
Browse files Browse the repository at this point in the history
…lues
  • Loading branch information
sijumoncy committed May 2, 2024
1 parent 2e15f6b commit 50a4a27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
const checkForConflictInSelectedBook = async (selectedBook) => {
// parse imported
const fs = window.require('fs');
console.log('READ ON CONTINUE LOAD ========> ', usfmJsons.conflictMeta.incomingPath, ' selected : ', selectedBook);
const IncomingUsfm = fs.readFileSync(path.join(usfmJsons.conflictMeta.incomingPath, selectedBook), 'utf8');
if (IncomingUsfm) {
const importedJson = await parseUsfm(IncomingUsfm);
Expand Down Expand Up @@ -159,8 +158,6 @@ function TranslationMergeUI({ conflictData, closeMergeWindow, triggerSnackBar })
setLoading(false);
};

console.log('PERF STATES >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ', { currentPerfInputArr, currentPerfResolveBookCode });

// Previous function to handle all books together ( JSON => usfm all together at the end )
// const handleFinishedResolution = async () => {
// const fs = window.require('fs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ async function processAndIdentiyVerseChangeinUSFMJsons(currentJson, IncomingJson
chapter.contents.forEach((content) => {
if (content.verseNumber) {
const IncomingVerse = IncomingChap.contents.find((ch) => ch.verseNumber === content.verseNumber);
// console.log(IncomingVerse);
if (content.verseText !== IncomingVerse.verseText) {
/**
* handle conflict detection coniditons
* conflict only if
* - both have valid string ([a-zA-Z0-9]) and not same
* - valid content in incoming , current can be anything
* */
if ((content.verseText !== IncomingVerse.verseText) && (/[a-zA-Z0-9]/.test(IncomingVerse.verseText))) {
// add incoming data
content.current = JSON.parse(JSON.stringify(content));
content.incoming = IncomingVerse;
Expand Down

0 comments on commit 50a4a27

Please sign in to comment.