Skip to content

Commit

Permalink
Cleaning up the code base
Browse files Browse the repository at this point in the history
  • Loading branch information
vipinpaul committed Sep 3, 2024
1 parent a9b022d commit 1fb4d4c
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 1 addition & 30 deletions renderer/src/components/ProjectManagement/ProjectManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -190,16 +171,6 @@ export default function ProjectMangement(props) {
setSnackText={setSnackText}
error={notify}
/>
{/* <ConfirmationModal
openModal={openModal}
title={t('modal-title-update-burrito')}
setOpenModal={setOpenModal}
confirmMessage={t('dynamic-msg-scope-difference', { scopediff: JSON.stringify(scopediff) })}
buttonName={t('btn-update')}
closeModal={
() => updateBurrito()
}
/> */}
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
}
};

Expand All @@ -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');
}
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
};
3 changes: 0 additions & 3 deletions renderer/src/components/Projects/ProjectList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export default function ProjectList() {
const filterList = ['name', 'language', 'type', 'date', 'view'];
const {
states: {
// starredProjects,
projects,
// unstarredProjects,
callEditProject,
},
action: {
Expand Down Expand Up @@ -59,7 +57,6 @@ export default function ProjectList() {
await FetchProjects();
};
const manageProject = (project) => {
console.log(project);
setCurrentProject(project);
setOpenManageProject(true);
};
Expand Down
1 change: 0 additions & 1 deletion renderer/src/layouts/editor/SectionContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const MainPlayer = dynamic(
);

const SectionContainer = () => {
console.log('section');
const [editor, setEditor] = useState();

useEffect(() => {
Expand Down
16 changes: 1 addition & 15 deletions renderer/src/modules/biblenavigation/BibleNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
},
Expand Down Expand Up @@ -135,6 +120,7 @@ export default function BibleNavigation(props) {
if (Object.keys(existingScopes) < 1) {
getProjectScope();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
Expand Down
30 changes: 0 additions & 30 deletions renderer/src/modules/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import * as logger from '../../logger';
export default function Editor({
children, callFrom, editor,
}) {
console.log('Editor', callFrom, editor);
const {
states: {
scrollLock,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1fb4d4c

Please sign in to comment.