@@ -28,6 +28,33 @@ import {
2828 shouldShowDesktopUpdateCheckIcon ,
2929} from "./DesktopUpdateStatusIcon" ;
3030
31+ function resolveSidebarUpdatePresentation ( {
32+ action,
33+ isDownloading,
34+ showCheckIcon,
35+ } : {
36+ readonly action : ReturnType < typeof resolveDesktopUpdateButtonAction > ;
37+ readonly isDownloading : boolean ;
38+ readonly showCheckIcon : boolean ;
39+ } ) {
40+ const showUpdateDetails = action !== "none" || isDownloading ;
41+ const iconStatus = showCheckIcon
42+ ? "checking"
43+ : action === "install"
44+ ? "downloaded"
45+ : isDownloading
46+ ? "downloading"
47+ : action === "download"
48+ ? "available"
49+ : "idle" ;
50+
51+ return {
52+ iconStatus,
53+ showUpdateDetails,
54+ showUpdateIconState : showUpdateDetails && ! showCheckIcon ,
55+ } as const ;
56+ }
57+
3158function keyReleaseNoteItems ( items : ReadonlyArray < string > ) {
3259 const occurrences = new Map < string , number > ( ) ;
3360 return items . map ( ( item ) => {
@@ -130,23 +157,26 @@ function SidebarUpdateControl() {
130157
131158 const action = state ? resolveDesktopUpdateButtonAction ( state ) : "none" ;
132159 const isDownloading = state ?. status === "downloading" ;
133- const isUpdateState = action !== "none" || isDownloading ;
134160 const showCheckIcon = shouldShowDesktopUpdateCheckIcon ( {
135161 isAnimationLatched : isCheckAnimationLatched ,
136162 isChecking : state ?. status === "checking" ,
137163 prefersReducedMotion,
138164 } ) ;
139- const showUpdateState = isUpdateState && ! showCheckIcon ;
140- const tooltip = showCheckIcon
141- ? "Checking for updates…"
142- : isUpdateState
143- ? state
144- ? getDesktopUpdateButtonTooltip ( state )
145- : "Update available"
165+ const { iconStatus, showUpdateDetails, showUpdateIconState } = resolveSidebarUpdatePresentation ( {
166+ action,
167+ isDownloading,
168+ showCheckIcon,
169+ } ) ;
170+ const tooltip = showUpdateDetails
171+ ? state
172+ ? getDesktopUpdateButtonTooltip ( state )
173+ : "Update available"
174+ : showCheckIcon
175+ ? "Checking for updates…"
146176 : "Check for updates" ;
147177 const disabled = showCheckIcon
148178 ? true
149- : isUpdateState
179+ : showUpdateDetails
150180 ? isDesktopUpdateButtonDisabled ( state )
151181 : ! canCheckForUpdate ( state ) ;
152182
@@ -274,16 +304,6 @@ function SidebarUpdateControl() {
274304 ) ;
275305 } , [ prefersReducedMotion , state ?. status ] ) ;
276306
277- const iconStatus = showCheckIcon
278- ? "checking"
279- : action === "install"
280- ? "downloaded"
281- : isDownloading
282- ? "downloading"
283- : action === "download"
284- ? "available"
285- : "idle" ;
286-
287307 return (
288308 < SidebarMenuItem className = "ml-auto shrink-0" >
289309 < Tooltip >
@@ -296,10 +316,10 @@ function SidebarUpdateControl() {
296316 disabled = { disabled || isActionPending }
297317 className = { cn (
298318 "inline-flex size-8 items-center justify-center rounded-full outline-hidden ring-ring transition-colors enabled:cursor-pointer focus-visible:ring-2 disabled:cursor-not-allowed" ,
299- showUpdateState
319+ showUpdateIconState
300320 ? "bg-update-surface text-update-foreground enabled:hover:bg-update/12"
301321 : "text-[var(--sidebar-icon-color)] enabled:hover:bg-sidebar-row-hover enabled:hover:text-sidebar-foreground" ,
302- disabled && ! showUpdateState && "opacity-60" ,
322+ disabled && ! showUpdateIconState && "opacity-60" ,
303323 ) }
304324 onClick = { handleAction }
305325 >
@@ -316,25 +336,25 @@ function SidebarUpdateControl() {
316336 < TooltipPopup
317337 align = "center"
318338 className = {
319- showUpdateState && state ?. channel === "nightly" && state . releaseNotes . length > 0
339+ showUpdateDetails && state ?. channel === "nightly" && state . releaseNotes . length > 0
320340 ? // pointer-events-auto overrides the positioner's pointer-events-none so the
321341 // release notes stay open (and scrollable) when the cursor moves into them.
322342 "pointer-events-auto max-w-none text-balance"
323343 : undefined
324344 }
325345 side = "top"
326346 style = {
327- showUpdateState
347+ showUpdateDetails
328348 ? {
329349 background :
330350 "color-mix(in srgb, var(--update) 18%, color-mix(in srgb, var(--popover) var(--glass-opacity), transparent))" ,
331351 borderColor : "var(--update-foreground)" ,
332352 }
333353 : undefined
334354 }
335- variant = { showUpdateState ? "glass" : "default" }
355+ variant = { showUpdateDetails ? "glass" : "default" }
336356 >
337- { showUpdateState && state ? (
357+ { showUpdateDetails && state ? (
338358 < SidebarUpdateReleaseNotesTooltip state = { state } tooltip = { tooltip } />
339359 ) : (
340360 tooltip
0 commit comments