diff --git a/react/src/FilePropertyDialog.tsx b/react/src/FilePropertyDialog.tsx index 7fdeecc..c387b8f 100644 --- a/react/src/FilePropertyDialog.tsx +++ b/react/src/FilePropertyDialog.tsx @@ -33,6 +33,7 @@ import AudioFileIcon from '@mui/icons-material/AudioFile'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import FolderIcon from '@mui/icons-material/Folder'; import InsertDriveFileOutlinedIcon from '@mui/icons-material/InsertDriveFileOutlined'; +import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile'; import DialogActions from '@mui/material/DialogActions'; import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; @@ -60,6 +61,32 @@ const styles = (theme: Theme) => createStyles({ }, }); +const audioFileExtensions: {[name: string]: boolean} = { + ".wav": true, + ".flac": true, + ".ogg": true, + ".aac": true, + ".au": true, + ".snd": true, + ".mid": true, + ".rmi": true, + ".mp3": true, + ".mp4": true, + ".aif": true, + ".aifc": true, + ".aiff": true, + ".ra": true +}; + +function isAudioFile(filename: string) { + let npos = filename.lastIndexOf('.'); + let nposSlash = filename.lastIndexOf('/'); + if (nposSlash >= npos) { + return false; + } + let extension = filename.substring(npos); + return audioFileExtensions[extension] !== undefined; +} export interface FilePropertyDialogProps extends WithStyles { open: boolean, @@ -470,6 +497,25 @@ export default withStyles(styles, { withTheme: true })( } return result; } + private getIcon(fileEntry: FileEntry) + { + if (fileEntry.filename === "") + { + return (); + } + if (fileEntry.isDirectory) + { + return ( + + ); + } + if (isAudioFile(fileEntry.filename)) + { + return (); + } + return (); + } + render() { let classes = this.props.classes; let columnWidth = this.state.columnWidth; @@ -571,12 +617,11 @@ export default withStyles(styles, { withTheme: true })( (this.state.columns !== 0) && // don't render until we have number of columns derived from layout. this.state.fileEntries.map( (value: FileEntry, index: number) => { - let isDefault = this.props.fileProperty.directory.startsWith("default"); let displayValue = value.filename; if (displayValue === "") { displayValue = ""; } else { - if (isDefault) + if (value.isDirectory) { displayValue = pathFileName(displayValue); } else { @@ -601,14 +646,7 @@ export default withStyles(styles, { withTheme: true })( >
- {value.filename === "" ? - () - : ( - value.isDirectory ? ( - - ) : ( - - ))} + {this.getIcon(value)} {displayValue}
@@ -725,7 +763,7 @@ export default withStyles(styles, { withTheme: true })( } openSelectedFile(): void { if (this.isDirectory(this.state.selectedFile)) { - let directoryName = pathFileNameOnly(this.state.selectedFile); + let directoryName = pathFileName(this.state.selectedFile); let navDirectory = pathConcat(this.state.navDirectory, directoryName); this.requestFiles(navDirectory); this.setState({ navDirectory: navDirectory });