Skip to content

Commit 280a527

Browse files
committed
Add warning that Mac OS X takes a while to boot
Show for 10 seconds the first 10 times Mac OS X booted (but can also be explicitly dismissed) Updates #357
1 parent 1108acf commit 280a527

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

src/Mac.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ body.fullscreen {
3333
border-radius: 10px;
3434
}
3535

36+
.Mac-Loading-Slow {
37+
white-space: nowrap;
38+
display: block;
39+
}
40+
41+
.Mac-Loading-Dismiss {
42+
margin-right: 8px;
43+
}
44+
3645
.Mac-Loading-Fraction {
3746
opacity: 0.5;
3847
padding-left: 0.5em;

src/Mac.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,26 @@ export default function Mac({
490490
);
491491
}
492492

493+
const {showMacOSXSlowNotification, clearMacOSXSlowNotification} =
494+
useMacOSXSlowNotification(
495+
!progress &&
496+
emulatorLoaded &&
497+
disks[0]?.infiniteHdSubset === "macosx"
498+
);
499+
if (showMacOSXSlowNotification) {
500+
progress = (
501+
<div className="Mac-Loading Mac-Loading-Non-Modal Mac-Loading-Slow">
502+
<span
503+
className="Mac-Loading-Dismiss"
504+
onClick={clearMacOSXSlowNotification}>
505+
506+
</span>
507+
Mac OS X may take a minute or two to start up, please be
508+
patient.
509+
</div>
510+
);
511+
}
512+
493513
function handleDragStart(event: React.DragEvent) {
494514
// Don't allow the screen to be dragged off when using a touchpad on
495515
// the iPad.
@@ -995,3 +1015,28 @@ function MacError({text, onDone}: {text: string; onDone: () => void}) {
9951015
</Dialog>
9961016
);
9971017
}
1018+
1019+
function useMacOSXSlowNotification(emulatorReady: boolean) {
1020+
const [count, setCount] = usePersistentState(
1021+
10,
1022+
"mac-os-x-slow-notification-count"
1023+
);
1024+
const [hide, setHide] = useState(false);
1025+
const shouldShow = count > 0 && emulatorReady;
1026+
1027+
useEffect(() => {
1028+
if (shouldShow) {
1029+
setCount(v => v - 1);
1030+
}
1031+
setTimeout(() => setHide(true), 10_000);
1032+
}, [setCount, shouldShow]);
1033+
1034+
const clearMacOSXSlowNotification = useCallback(
1035+
() => setCount(0),
1036+
[setCount]
1037+
);
1038+
return {
1039+
showMacOSXSlowNotification: shouldShow && !hide,
1040+
clearMacOSXSlowNotification,
1041+
};
1042+
}

0 commit comments

Comments
 (0)