Skip to content

Commit 1aa4ce5

Browse files
committed
chore(web): remove test mocks from SidebarUpdatePill
Restore real bridge subscription and isElectron checks that were hardcoded for local testing.
1 parent 2003d74 commit 1aa4ce5

File tree

1 file changed

+35
-53
lines changed

1 file changed

+35
-53
lines changed

apps/web/src/components/sidebar/SidebarUpdatePill.tsx

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,48 @@ import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
1717
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
1818

1919
export function SidebarUpdatePill() {
20-
// TODO: REMOVE - hardcoded for testing arm64 warning
21-
const [state, setState] = useState<DesktopUpdateState | null>({
22-
enabled: true,
23-
status: "available",
24-
currentVersion: "1.0.0",
25-
availableVersion: "1.2.3",
26-
downloadedVersion: null,
27-
downloadPercent: null,
28-
checkedAt: new Date().toISOString(),
29-
message: null,
30-
errorContext: null,
31-
hostArch: "arm64",
32-
appArch: "x64",
33-
runningUnderArm64Translation: true,
34-
canRetry: false,
35-
});
20+
const [state, setState] = useState<DesktopUpdateState | null>(null);
3621
const [dismissed, setDismissed] = useState(false);
3722

38-
// TODO: REMOVE - disabled for testing
39-
// useEffect(() => {
40-
// if (!isElectron) return;
41-
// const bridge = window.desktopBridge;
42-
// if (
43-
// !bridge ||
44-
// typeof bridge.getUpdateState !== "function" ||
45-
// typeof bridge.onUpdateState !== "function"
46-
// ) {
47-
// return;
48-
// }
49-
//
50-
// let disposed = false;
51-
// let receivedSubscriptionUpdate = false;
52-
// const unsubscribe = bridge.onUpdateState((nextState) => {
53-
// if (disposed) return;
54-
// receivedSubscriptionUpdate = true;
55-
// setState(nextState);
56-
// });
57-
//
58-
// void bridge
59-
// .getUpdateState()
60-
// .then((nextState) => {
61-
// if (disposed || receivedSubscriptionUpdate) return;
62-
// setState(nextState);
63-
// })
64-
// .catch(() => undefined);
65-
//
66-
// return () => {
67-
// disposed = true;
68-
// unsubscribe();
69-
// };
70-
// }, []);
23+
useEffect(() => {
24+
if (!isElectron) return;
25+
const bridge = window.desktopBridge;
26+
if (
27+
!bridge ||
28+
typeof bridge.getUpdateState !== "function" ||
29+
typeof bridge.onUpdateState !== "function"
30+
) {
31+
return;
32+
}
33+
34+
let disposed = false;
35+
let receivedSubscriptionUpdate = false;
36+
const unsubscribe = bridge.onUpdateState((nextState) => {
37+
if (disposed) return;
38+
receivedSubscriptionUpdate = true;
39+
setState(nextState);
40+
});
41+
42+
void bridge
43+
.getUpdateState()
44+
.then((nextState) => {
45+
if (disposed || receivedSubscriptionUpdate) return;
46+
setState(nextState);
47+
})
48+
.catch(() => undefined);
49+
50+
return () => {
51+
disposed = true;
52+
unsubscribe();
53+
};
54+
}, []);
7155

72-
// TODO: REMOVE - bypassed isElectron for testing
73-
const visible = /* isElectron && */ shouldShowDesktopUpdateButton(state) && !dismissed;
56+
const visible = isElectron && shouldShowDesktopUpdateButton(state) && !dismissed;
7457
const tooltip = state ? getDesktopUpdateButtonTooltip(state) : "Update available";
7558
const disabled = isDesktopUpdateButtonDisabled(state);
7659
const action = state ? resolveDesktopUpdateButtonAction(state) : "none";
7760

78-
// TODO: REMOVE - bypassed isElectron for testing
79-
const showArm64Warning = /* isElectron && */ shouldShowArm64IntelBuildWarning(state);
61+
const showArm64Warning = isElectron && shouldShowArm64IntelBuildWarning(state);
8062
const arm64Description =
8163
state && showArm64Warning ? getArm64IntelBuildWarningDescription(state) : null;
8264

0 commit comments

Comments
 (0)