From 1fb4d4cff12b4ca483f015da3df6859d8193d752 Mon Sep 17 00:00:00 2001 From: vipinpaul Date: Tue, 3 Sep 2024 11:48:23 +0530 Subject: [PATCH] Cleaning up the code base --- .../EditorPage/AudioEditor/AudioEditor.js | 1 - .../Navigation/reference/SelectBook.js | 1 - .../Navigation/reference/SelectVerse.js | 1 - .../ProjectManagement/ProjectManagement.js | 31 +------------------ .../scope-management/ScopeManagement.jsx | 5 +-- .../utils/readProjectScope.js | 4 +-- .../src/components/Projects/ProjectList.js | 3 -- .../src/layouts/editor/SectionContainer.js | 1 - .../biblenavigation/BibleNavigation.js | 16 +--------- renderer/src/modules/editor/Editor.js | 30 ------------------ 10 files changed, 7 insertions(+), 86 deletions(-) diff --git a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js index 54e89b92..793151c6 100644 --- a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js +++ b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js @@ -17,7 +17,6 @@ import { getDetails } from '../ObsEditor/utils/getDetails'; const grammar = require('usfm-grammar'); const AudioEditor = ({ editor }) => { - console.log('Audio editor'); const [snackBar, setOpenSnackBar] = useState(false); const [snackText, setSnackText] = useState(''); const [notify, setNotify] = useState(); diff --git a/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js b/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js index cbf19e17..40261083 100644 --- a/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js +++ b/renderer/src/components/EditorPage/Navigation/reference/SelectBook.js @@ -18,7 +18,6 @@ export default function SelectBook({ disableScope = {}, call = '', }) { - console.log('existingScope', disableScope, selectedBooks); const [openNT, setOpenNT] = useState(true); const [openOT, setOpenOT] = useState(true); diff --git a/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js b/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js index d0a079dc..ba564b1c 100644 --- a/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js +++ b/renderer/src/components/EditorPage/Navigation/reference/SelectVerse.js @@ -27,7 +27,6 @@ export default function SelectVerse({ scopedChapters, call = '', }) { - console.log('scopedChapters', scopedChapters); const [controlVerseSelect, setControlVerseSelect] = useState([]); const [openChapter, setOpenChapter] = useState(true); const [openVerse, setOpenVerse] = useState(false); diff --git a/renderer/src/components/ProjectManagement/ProjectManagement.js b/renderer/src/components/ProjectManagement/ProjectManagement.js index 91c35402..54d8cc5a 100644 --- a/renderer/src/components/ProjectManagement/ProjectManagement.js +++ b/renderer/src/components/ProjectManagement/ProjectManagement.js @@ -9,9 +9,7 @@ import PropTypes from 'prop-types'; import { Dialog, Transition } from '@headlessui/react'; import { useTranslation } from 'react-i18next'; import { SnackBar } from '@/components/SnackBar'; -// import useSystemNotification from '@/components/hooks/useSystemNotification'; // import { LoadingSpinner } from '@/components/LoadingSpinner'; -// import ConfirmationModal from '@/layouts/editor/ConfirmationModal'; import CloseIcon from '@/illustrations/close-button-black.svg'; import * as logger from '../../logger'; import ScopeManagement from './scope-management/ScopeManagement'; @@ -51,7 +49,7 @@ export default function ProjectMangement(props) { setMetadata(projectMeta.metadata); setBackendScope(projectMeta.scope); } catch (err) { - console.error('Read Meta : ', err); + logger.error('ProjectMangement.js', `Read Meta : ${err}`); } finally { setLoading(false); } @@ -87,23 +85,6 @@ export default function ProjectMangement(props) { }); }; - // const handleProject = () => { - // metadata.type.flavorType.currentScope = currentScope; - // const projectFullName = `${project?.name}_${project?.id?.[0]}`; - // // updateBurritoScope checks whether user has removed anything (Book(s)/Chapter(s)) from the existing scope or not - // updateBurritoScope(projectFullName, metadata, 'difference').then((value) => { - // console.log('scope', value); - // if (Object.keys(value).length > 0) { - // // Has some change so merge is required - // setScopeDiff(value); - // // setOpenModal(true); - // } else { - // // nothing been removed by the user - // updateBurrito(); - // } - // }); - // }; - useEffect(() => { getProjectMetadata(); }, [getProjectMetadata]); @@ -190,16 +171,6 @@ export default function ProjectMangement(props) { setSnackText={setSnackText} error={notify} /> - {/* updateBurrito() - } - /> */} ); } diff --git a/renderer/src/components/ProjectManagement/scope-management/ScopeManagement.jsx b/renderer/src/components/ProjectManagement/scope-management/ScopeManagement.jsx index 24675600..87961a39 100644 --- a/renderer/src/components/ProjectManagement/scope-management/ScopeManagement.jsx +++ b/renderer/src/components/ProjectManagement/scope-management/ScopeManagement.jsx @@ -6,6 +6,7 @@ import BookButton from '../Common/Button/BookButton'; import BulkSelectionGroup from './BulkSelectionGroup'; import Button from '../Common/Button/Button'; import BookItem from './BookItem'; +import * as logger from '../../../logger'; const initialBook = 'gen'; const initialChapter = '1'; @@ -154,7 +155,7 @@ function ScopeManagement({ }; }); } else { - console.error('Active book is not in scope '); + logger.error('ScopeManagement.js', 'Active book is not in scope'); } }; @@ -168,7 +169,7 @@ function ScopeManagement({ onChangeBook(bookCode, bookCode); setCurrentScope(scopeObj); } else { - console.error('unable to get the scope'); + logger.error('ScopeManagement.js', 'Unable to read the scope from burrito'); } }, []); diff --git a/renderer/src/components/ProjectManagement/utils/readProjectScope.js b/renderer/src/components/ProjectManagement/utils/readProjectScope.js index cdc6285b..ca1a6e79 100644 --- a/renderer/src/components/ProjectManagement/utils/readProjectScope.js +++ b/renderer/src/components/ProjectManagement/utils/readProjectScope.js @@ -46,7 +46,7 @@ export const readProjectScope = async (projectName) => { if (fs.existsSync(filePath)) { const metadataFile = await fs.readFileSync(filePath, 'utf-8'); if (metadataFile) { - logger.debug('metadataFile.js', `read metadata file successfully - ${projectName}`); + logger.debug('readProjectScope.js', `read metadata file successfully - ${projectName}`); const project = path.join(file, projectName, 'audio', 'ingredients'); const backendScope = getScope(project); const json = await JSON.parse(metadataFile); @@ -56,7 +56,7 @@ export const readProjectScope = async (projectName) => { } throw new Error(`failed to read metadata file - ${projectName}`); } catch (err) { - logger.error('metadataFile.js', `read metadata file successfully - ${projectName}`); + logger.error('readProjectScope.js', `read metadata file successfully - ${projectName}`); throw new Error(err?.message || err); } }; diff --git a/renderer/src/components/Projects/ProjectList.js b/renderer/src/components/Projects/ProjectList.js index 020d6ccd..8485de3b 100644 --- a/renderer/src/components/Projects/ProjectList.js +++ b/renderer/src/components/Projects/ProjectList.js @@ -26,9 +26,7 @@ export default function ProjectList() { const filterList = ['name', 'language', 'type', 'date', 'view']; const { states: { - // starredProjects, projects, - // unstarredProjects, callEditProject, }, action: { @@ -59,7 +57,6 @@ export default function ProjectList() { await FetchProjects(); }; const manageProject = (project) => { - console.log(project); setCurrentProject(project); setOpenManageProject(true); }; diff --git a/renderer/src/layouts/editor/SectionContainer.js b/renderer/src/layouts/editor/SectionContainer.js index 84594e87..4e4415eb 100644 --- a/renderer/src/layouts/editor/SectionContainer.js +++ b/renderer/src/layouts/editor/SectionContainer.js @@ -15,7 +15,6 @@ const MainPlayer = dynamic( ); const SectionContainer = () => { - console.log('section'); const [editor, setEditor] = useState(); useEffect(() => { diff --git a/renderer/src/modules/biblenavigation/BibleNavigation.js b/renderer/src/modules/biblenavigation/BibleNavigation.js index d5e51e8e..0be06ca3 100644 --- a/renderer/src/modules/biblenavigation/BibleNavigation.js +++ b/renderer/src/modules/biblenavigation/BibleNavigation.js @@ -10,20 +10,11 @@ import { import * as localforage from 'localforage'; import SelectBook from '@/components/EditorPage/Navigation/reference/SelectBook'; import SelectVerse from '@/components/EditorPage/Navigation/reference/SelectVerse'; - -// import { -// LockOpenIcon, -// LockClosedIcon, -// BookmarkIcon, -// CogIcon, -// ChatIcon, -// } from '@heroicons/react/24/outline'; import { ReferenceContext } from '@/components/context/ReferenceContext'; import { splitStringByLastOccurence } from '@/util/splitStringByLastMarker'; import { isElectron } from '../../core/handleElectron'; export default function BibleNavigation(props) { - console.log('Navigation'); const { showVerse } = props; const supportedBooks = null; // if empty array or null then all books available @@ -82,20 +73,14 @@ export default function BibleNavigation(props) { } const getProjectScope = () => { - console.log('getProjectScope - Bible Navigation'); localforage.getItem('currentProject').then(async (projectName) => { const _projectname = await splitStringByLastOccurence(projectName, '_'); - // const _projectname = projectName?.split('_'); localforage.getItem('projectmeta').then((value) => { - console.log(value); Object?.entries(value).forEach( ([, _value]) => { - console.log(_value); Object?.entries(_value).forEach( ([, resources]) => { - console.log(resources); if (resources.identification.name.en === _projectname[0]) { - console.log('resource', resources.type.flavorType.currentScope); setExistingScopes(resources.type.flavorType.currentScope); } }, @@ -135,6 +120,7 @@ export default function BibleNavigation(props) { if (Object.keys(existingScopes) < 1) { getProjectScope(); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { diff --git a/renderer/src/modules/editor/Editor.js b/renderer/src/modules/editor/Editor.js index a64a9170..ebb911d2 100644 --- a/renderer/src/modules/editor/Editor.js +++ b/renderer/src/modules/editor/Editor.js @@ -21,7 +21,6 @@ import * as logger from '../../logger'; export default function Editor({ children, callFrom, editor, }) { - console.log('Editor', callFrom, editor); const { states: { scrollLock, @@ -63,36 +62,7 @@ export default function Editor({ } }; - const getProjectScope = () => { - console.log('getProjectScope'); - localforage.getItem('currentProject').then(async (projectName) => { - const _projectname = await splitStringByLastOccurence(projectName, '_'); - // const _projectname = projectName?.split('_'); - localforage.getItem('projectmeta').then((value) => { - console.log(value); - Object?.entries(value).forEach( - ([, _value]) => { - console.log(_value); - Object?.entries(_value).forEach( - ([, resources]) => { - console.log(resources); - if (resources.identification.name.en === _projectname[0]) { - console.log('resource', resources); - } - }, - ); - }, - ); - }); - }); - }; - - useEffect(() => { - getProjectScope; - }, [chapter]); - useEffect(() => { - console.log(callFrom, editor); if (((bookmarksVerses?.find((x) => x.bookname === bookName && x.chapter === chapter) !== undefined))) { setBookMarks(true);