From 58645b5f0d83bbe0d2b1d6a3e2a258bd96f9f7a6 Mon Sep 17 00:00:00 2001 From: danielc-n Date: Fri, 18 Oct 2024 16:50:54 +0200 Subject: [PATCH] few bugfix, regarding juxtalinear editor and renaming the translationHelpImageCard to translationHelpMultimediaCard --- .../Navigation/reference/SelectBook.js | 2 +- .../EditorPage/Reference/TranslationHelps.js | 5 +- .../Reference/TranslationHelpsCard.js | 24 ++- .../Reference/TranslationHelpsImageCard.js | 177 ------------------ .../EditorPage/TextEditor/index.jsx | 2 +- 5 files changed, 23 insertions(+), 187 deletions(-) delete mode 100644 renderer/src/components/EditorPage/Reference/TranslationHelpsImageCard.js diff --git a/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js b/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js index cb28054e..e4642727 100644 --- a/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js +++ b/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js @@ -38,7 +38,7 @@ export default function SelectBook({ function bookSelect(e, bookId) { e.preventDefault(); onChangeBook(bookId, selectedBooks[0]); - setBook(bookId); + setBook && setBook(bookId); if (multiSelectBook === false) { selectBook(); } } diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelps.js b/renderer/src/components/EditorPage/Reference/TranslationHelps.js index b04e789c..5a45f9c5 100644 --- a/renderer/src/components/EditorPage/Reference/TranslationHelps.js +++ b/renderer/src/components/EditorPage/Reference/TranslationHelps.js @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'; import { ReferenceContext } from '@/components/context/ReferenceContext'; import { debug } from '../../../logger'; import TranslationHelpsCard from './TranslationHelpsCard'; -import TranslationHelpsImageCard from './TranslationHelpsImageCard'; +import TranslationHelpsMultimediaCard from './TranslationHelpsMultimediaCard'; import ObsTnCard from './OBS/ObsTn'; import ObsTwlCard from './OBS/ObsTwlCard'; import packageInfo from '../../../../../package.json'; @@ -50,7 +50,6 @@ const TranslationHelps = ({ const pathRelationFile = path.resolve(pathToIngredients, 'relation.txt'); if (fs.existsSync(pathRelationFile)) { - console.log("HERE WHAT NOPE") setImagesPath(pathToIngredients); const relationFileContent = fs.readFileSync(pathRelationFile, 'utf8'); const fileName = findFileByPartialName(fs, path.resolve(resourceDirPath), relationFileContent.trim()); @@ -93,7 +92,7 @@ const TranslationHelps = ({ ); case 'tir': return ( - { + // currentFile = asArray.filter(([key, value]) => { + // if (key.toLocaleLowerCase().indexOf(projectId.toLowerCase()) !== -1) { + // console.log("key ==", key); + // console.log("value ==", value); + // return value; + // } + // return []; + // })[0]; + console.log("projectId.toLowerCase() ==", projectId.toLowerCase()); + for (let [key, value] of asArray) { if (key.toLocaleLowerCase().indexOf(projectId.toLowerCase()) !== -1) { - return value; + console.log("key == ", key) + console.log("value == ", value) + currentFile = key; + break; } - return []; - })[0]; + } + console.log("currentFile IN IF", currentFile) } else { currentFile = offlineResource?.data?.value?.projects.filter((item) => { if (item?.identifier.toLowerCase() === projectId.toLowerCase()) { @@ -122,9 +134,11 @@ export default function TranslationHelpsCard({ return null; }); } + console.log("currentFile OUT IF", currentFile) if (currentFile?.length > 0) { // const filecontent = await fs.readFileSync(path.join(folder, projectName, currentFile[0].path), 'utf8'); - const filecontent = await fs.readFileSync(path.join(folder, projectName, isBurrito ? currentFile[0] : currentFile[0].path), 'utf8'); + const filecontent = await fs.readFileSync(path.join(folder, projectName, isBurrito ? currentFile : currentFile[0].path), 'utf8'); + console.log("currentFile[0]", currentFile[0]) // convert tsv to json const headerArr = filecontent.split('\n')[0].split('\t'); let noteName; diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelpsImageCard.js b/renderer/src/components/EditorPage/Reference/TranslationHelpsImageCard.js deleted file mode 100644 index 6e21d114..00000000 --- a/renderer/src/components/EditorPage/Reference/TranslationHelpsImageCard.js +++ /dev/null @@ -1,177 +0,0 @@ -/* eslint-disable */ -// import PropTypes from 'prop-types'; -import React, { useEffect, useState } from 'react'; -import i18n from '../../../translations/i18n'; - -const VideoPlayer = ({ videoUrl }) => { - const [videoSrc, setVideoSrc] = useState(videoUrl); // Default to remote video URL - - useEffect(() => { - const loadVideo = async () => { - // Check if video is already cached - const cachedVideoPath = await global.ipcRenderer.invoke('is-video-cached', videoUrl); - if (cachedVideoPath) { - setVideoSrc(`file://${cachedVideoPath}`); // Use cached video path - } else { - // If not cached, download and cache the video - const downloadedPath = await global.ipcRenderer.invoke('download-and-cache-video', videoUrl); - setVideoSrc(`file://${downloadedPath}`); // Set downloaded video path - } - }; - - loadVideo(); - }, [videoUrl]); - - return ( -