PsfPlayer: revokeObjectURL.

This commit is contained in:
Jean-Philip Desjardins 2022-01-20 18:58:37 -05:00
parent e3a48b8b7f
commit 5ec3ee4632
2 changed files with 5 additions and 4 deletions

View file

@ -51,8 +51,9 @@ export const init = createAsyncThunk<void>('init',
}
);
export const loadArchive = createAsyncThunk<string[] | undefined, string>('loadArchive',
async (url : string, thunkAPI) => {
export const loadArchive = createAsyncThunk<string[] | undefined, File>('loadArchive',
async (file : File, thunkAPI) => {
let url = URL.createObjectURL(file);
console.log(`loading ${url}...`);
await stopPsf();
let blob = await fetch(url).then(response => {
@ -70,6 +71,7 @@ export const loadArchive = createAsyncThunk<string[] | undefined, string>('loadA
let stream = PsfPlayerModule.FS.open(archiveFilePath, "w+");
PsfPlayerModule.FS.write(stream, data, 0, data.length, 0);
PsfPlayerModule.FS.close(stream);
URL.revokeObjectURL(url);
let fileList = getPsfArchiveFileList(archiveFilePath);
fileList = fileList.filter(path =>
path.endsWith(".psf") ||

View file

@ -82,8 +82,7 @@ export default function App() {
const handleChange = function(event : ChangeEvent<HTMLInputElement>) {
if(event.target && event.target.files && event.target.files.length !== 0) {
var url = URL.createObjectURL(event.target.files[0]);
dispatch(loadArchive(url));
dispatch(loadArchive(event.target.files[0]));
}
}