@@ -5,9 +5,13 @@ import { Button } from "../../ui/Button";
55import { Copy , Star , Check , Trash2 , FolderOpen } from "lucide-react" ;
66import { convertFileSrc } from "@tauri-apps/api/core" ;
77import { listen } from "@tauri-apps/api/event" ;
8+ import { platform } from "@tauri-apps/plugin-os" ;
9+ import { readFile } from "@tauri-apps/plugin-fs" ;
810import { commands , type HistoryEntry } from "@/bindings" ;
911import { formatDateTime } from "@/utils/dateFormat" ;
1012
13+ const IS_LINUX = platform ( ) === "linux" ;
14+
1115interface OpenRecordingsButtonProps {
1216 onClick : ( ) => void ;
1317 label : string ;
@@ -93,7 +97,14 @@ export const HistorySettings: React.FC = () => {
9397 try {
9498 const result = await commands . getAudioFilePath ( fileName ) ;
9599 if ( result . status === "ok" ) {
96- return convertFileSrc ( `${ result . data } ` , "asset" ) ;
100+ if ( IS_LINUX ) {
101+ const fileData = await readFile ( result . data ) ;
102+ const blob = new Blob ( [ fileData ] , { type : "audio/wav" } ) ;
103+
104+ return URL . createObjectURL ( blob ) ;
105+ }
106+
107+ return convertFileSrc ( result . data , "asset" ) ;
97108 }
98109 return null ;
99110 } catch ( error ) {
@@ -222,12 +233,30 @@ const HistoryEntryComponent: React.FC<HistoryEntryProps> = ({
222233 const [ showCopied , setShowCopied ] = useState ( false ) ;
223234
224235 useEffect ( ( ) => {
236+ let cancelled = false ;
237+ let urlToRevoke : string | null = null ;
238+
225239 const loadAudio = async ( ) => {
226240 const url = await getAudioUrl ( entry . file_name ) ;
227- setAudioUrl ( url ) ;
241+
242+ if ( ! cancelled ) {
243+ urlToRevoke = url ;
244+ setAudioUrl ( url ) ;
245+ } else if ( url ?. startsWith ( "blob:" ) ) {
246+ URL . revokeObjectURL ( url ) ;
247+ }
228248 } ;
249+
229250 loadAudio ( ) ;
230- } , [ entry . file_name , getAudioUrl ] ) ;
251+
252+ return ( ) => {
253+ cancelled = true ;
254+
255+ if ( urlToRevoke ?. startsWith ( "blob:" ) ) {
256+ URL . revokeObjectURL ( urlToRevoke ) ;
257+ }
258+ } ;
259+ } , [ entry . file_name ] ) ;
231260
232261 const handleCopyText = ( ) => {
233262 onCopyText ( ) ;
0 commit comments