Skip to content

Commit

Permalink
Allow direct drag-and-drop of CD-ROM URLs
Browse files Browse the repository at this point in the history
Updates #166
Updates #48
  • Loading branch information
mihaip committed Aug 1, 2023
1 parent f586f50 commit a372439
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Mac.tsx
Expand Up @@ -38,6 +38,7 @@ import {MacCDROMs} from "./MacCDROMs";
import {type Appearance} from "./controls/Appearance";
import {Select} from "./controls/Select";
import {Checkbox} from "./controls/Checkbox";
import {fetchCDROMInfo} from "./cdroms";

export type MacProps = {
disks: SystemDiskDef[];
Expand Down Expand Up @@ -325,6 +326,22 @@ export default function Mac({
for (const item of event.dataTransfer.items) {
if (item.kind === "file") {
files.push(item.getAsFile()!);
} else if (
item.kind === "string" &&
item.type === "text/uri-list"
) {
item.getAsString(async url => {
try {
const cdrom = await fetchCDROMInfo(url);
varz.increment("emulator_cdrom:drag");
emulatorRef.current?.loadCDROM(cdrom);
} catch (e) {
// TODO: try to use CORS to fetch the file directly
// and upload it?
console.log("error fetching cdrom", e);
return;
}
});
}
}
} else if (event.dataTransfer.files) {
Expand Down

0 comments on commit a372439

Please sign in to comment.