Skip to content

Commit 0d14ac0

Browse files
committed
TT-4686, TT-3970 Creating audacity files (#1070)
- Add Passage Description to Audio Manager dialog title
1 parent 3724bbe commit 0d14ac0

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

craco.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
// eslint-disable-next-line no-param-reassign
66
config.resolve.fallback = {
77
fs: require.resolve('fs'),
8+
'process/browser': require.resolve('process/browser'),
89
};
910
config.plugins.push(
1011
new webpack.ProvidePlugin({

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"node-html-encoder": "0.0.2",
4545
"original-fs": "^1.1.0",
4646
"path-browserify": "^1.0.1",
47+
"process": "^0.11.10",
4748
"react": "^18.2.0",
4849
"react-datasheet": "^1.4.9",
4950
"react-dom": "^18.2.0",
@@ -207,7 +208,5 @@
207208
]
208209
}
209210
]
210-
},
211-
"main": "public/electron.js",
212-
"homepage": "./"
211+
}
213212
}

src/components/Workflow/AudacityManager.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { useGlobal } from 'reactn';
33
import moment from 'moment';
44
import { shallowEqual, useSelector } from 'react-redux';
5-
import { IAudacityManagerStrings, MediaFile } from '../../model';
5+
import { IAudacityManagerStrings, IState, MediaFile } from '../../model';
66
import {
77
Button,
88
Dialog,
@@ -22,6 +22,8 @@ import {
2222
useAudacityProjRead,
2323
useAudacityProjDelete,
2424
useAudProjName,
25+
usePassageRec,
26+
passageDescription,
2527
} from '../../crud';
2628
import { useSnackBar } from '../../hoc/SnackBar';
2729
import { debounce } from 'lodash';
@@ -74,6 +76,9 @@ function AudacityManager(props: IProps) {
7476
const { passageId, mediaId, onClose, open } = props;
7577
const { item, onImport } = props;
7678
const { speaker, onSpeaker } = props;
79+
const allBookData = useSelector((state: IState) => state.books.bookData);
80+
const getPassage = usePassageRec();
81+
const [passageRef, setPassageRef] = React.useState('');
7782
const [hasRights, setHasRight] = React.useState(!onSpeaker);
7883
const audUpdate = useAudacityProjUpdate();
7984
const audRead = useAudacityProjRead();
@@ -293,6 +298,10 @@ function AudacityManager(props: IProps) {
293298
nameUpdate();
294299
}
295300
})();
301+
if (passageId?.id) {
302+
const passRec = getPassage(passageId.id);
303+
setPassageRef(passageDescription(passRec, allBookData));
304+
}
296305
// eslint-disable-next-line react-hooks/exhaustive-deps
297306
}, [passageId, name]);
298307

@@ -304,7 +313,7 @@ function AudacityManager(props: IProps) {
304313
maxWidth="md"
305314
disableEnforceFocus
306315
>
307-
<DialogTitle id="manager-title">{t.title}</DialogTitle>
316+
<DialogTitle id="manager-title">{`${t.title} - ${passageRef}`}</DialogTitle>
308317
<StyledGrid container>
309318
{exists && name !== '' ? (
310319
<Grid container justifyContent="center">

src/crud/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export * from './useFlatAdd';
2020
export * from './useIsPersonalTeam';
2121
export * from './useNewTeamId';
2222
export * from './useOrganizedBy';
23+
export * from './usePassageRec';
2324
export * from './usePlan';
2425
export * from './useProjectPlans';
2526
export * from './user';

src/crud/usePassageRec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { QueryBuilder } from '@orbit/data';
2+
import { useGlobal } from 'reactn';
3+
import { Passage } from '../model';
4+
5+
export const usePassageRec = () => {
6+
const [memory] = useGlobal('memory');
7+
8+
return (passageid: string) => {
9+
return memory.cache.query((q: QueryBuilder) =>
10+
q.findRecord({ type: 'passage', id: passageid })
11+
) as Passage;
12+
};
13+
};

src/utils/launchAudacity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IExeca } from '../model';
22
import { getAudacityExe, logError, Severity, infoMsg, execFolder } from '.';
33
import path from 'path-browserify';
4+
import process from 'process';
45
const ipc = (window as any)?.electron;
56

67
export const launchAudacity = async (proj: string, reporter: any) => {

0 commit comments

Comments
 (0)