- {backendScope && bookList?.slice(0, 39)?.map((book) => {
+ {bookList?.slice(0, 39)?.map((book) => {
const isScope = book?.key?.toUpperCase() in currentScope;
return (
);
})}
@@ -207,7 +207,7 @@ function ScopeManagement({
- {backendScope && bookList?.slice(39)?.map((book) => {
+ {bookList?.slice(39)?.map((book) => {
const isScope = book?.key?.toUpperCase() in currentScope;
return (
);
})}
@@ -270,7 +270,7 @@ function ScopeManagement({
{chapterList?.map(({ key, name }) => {
const isInScope = selectedChaptersSet.has(key);
- const disable = backendScope[bookId.toUpperCase()]?.includes(key);
+ const disable = backendScope && backendScope[bookId.toUpperCase()]?.includes(key);
return (
handleChapterSelection(e, name)}
diff --git a/renderer/src/components/ProjectManagement/utils/readProjectScope.js b/renderer/src/components/ProjectManagement/utils/readProjectScope.js
index ca1a6e79..a86cce73 100644
--- a/renderer/src/components/ProjectManagement/utils/readProjectScope.js
+++ b/renderer/src/components/ProjectManagement/utils/readProjectScope.js
@@ -11,26 +11,32 @@ const getDirectories = (readdirSync, source) => readdirSync(source, { withFileTy
.map((dirent) => dirent.name);
// This function returns the Object of books & chapters which has atleast 1 audio file in it.
-export const getScope = (project) => {
+export const getScope = async (project) => {
const path = require('path');
const scope = {};
const { readdirSync } = window.require('fs');
const fs = window.require('fs');
const list = getDirectories(readdirSync, project);
- list.forEach((book) => {
+
+ list.forEach(async (book) => {
const chapters = getDirectories(readdirSync, path.join(project, book));
const chapterFilter = [];
- chapters.forEach((chapter) => {
+ let flag = false;
+ await Promise.all(chapters.map(async (chapter) => {
+ // for (const chapter of chapters) {
// Finding non empty directories/chapters
- isDirEmpty(path.join(project, book, chapter), fs).then((value) => {
+ await isDirEmpty(path.join(project, book, chapter), fs).then((value) => {
if (value === true) {
- chapterFilter.push(chapter);
+ flag = true;
+ return chapterFilter.push(chapter);
}
});
- });
- scope[book] = chapterFilter;
+ }));
+ if (flag === true) {
+ scope[book] = chapterFilter;
+ }
});
- return scope;
+return scope;
};
export const readProjectScope = async (projectName) => {
try {
@@ -48,7 +54,7 @@ export const readProjectScope = async (projectName) => {
if (metadataFile) {
logger.debug('readProjectScope.js', `read metadata file successfully - ${projectName}`);
const project = path.join(file, projectName, 'audio', 'ingredients');
- const backendScope = getScope(project);
+ const backendScope = await getScope(project);
const json = await JSON.parse(metadataFile);
return { metadata: json, scope: backendScope };
}
diff --git a/renderer/src/components/Projects/ProjectRow.js b/renderer/src/components/Projects/ProjectRow.js
index 1dbbe727..5b86b8fd 100644
--- a/renderer/src/components/Projects/ProjectRow.js
+++ b/renderer/src/components/Projects/ProjectRow.js
@@ -245,7 +245,7 @@ const ProjectRow = ({
} group rounded-md items-center w-full px-2 py-2 text-sm ${project.isArchived ? 'hidden' : 'flex'}`}
onClick={() => manageProject(project)}
>
- Manage Project
+ Scope Management
)}
diff --git a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js
index fe82639c..4d2a2f9f 100644
--- a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js
+++ b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js
@@ -260,7 +260,8 @@ export default function AdvancedSettingsDropdown({ call, project, projectType })