Commit ba4b004d authored by Kourser's avatar Kourser
Browse files

fix(macos): tame the episodes popover content, silence the Swift 6 warning

The base bar now renders on hardware; expanding the popover blanked it.
Two likely culprits in its content, both removed:

- The episodes scrubber carried the same stretch constraint (1200 pt,
  low priority) that already blanked the bar once; it now uses the
  proven shape (plain <=800 pt cap, no stretch).
- The scrubber selection was reset synchronously inside the touch
  gesture callback; the reset now runs on the next main-actor turn.

Also asserts the NSScrubberFlowLayoutDelegate conformance as
@preconcurrency (AppKit calls it on the main thread), clearing the
Swift 6 data-race warning the user reported.

Co-Authored-By: Claude (RCA)
parent 5d5b1a8c
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -225,11 +225,13 @@ extension TouchBarController: NSTouchBarDelegate {
            podcastScrubber = scrubber
            return item
        case .skingomzEpisodes:
            // Same proven shape as the podcasts strip: a plain cap, no
            // stretching constraint (those blanked the bar).
            let item = NSCustomTouchBarItem(identifier: identifier)
            let scrubber = makeScrubber()
            scrubber.register(NSScrubberTextItemView.self, forItemIdentifier: Self.episodeCell)
            scrubber.scrubberLayout = NSScrubberFlowLayout() // sized per title below
            Self.stretch(scrubber)
            scrubber.widthAnchor.constraint(lessThanOrEqualToConstant: 800).isActive = true
            item.view = scrubber
            episodeScrubber = scrubber
            return item
@@ -257,18 +259,10 @@ extension TouchBarController: NSTouchBarDelegate {
        scrubber.showsAdditionalContentIndicators = true
        return scrubber
    }

    /// A scrubber has no intrinsic width: alone in the bar it collapses to
    /// nothing. This low-priority width makes it soak up the available space
    /// while still yielding to the other items (and to the 320 pt cap).
    private static func stretch(_ scrubber: NSScrubber) {
        let width = scrubber.widthAnchor.constraint(equalToConstant: 1200)
        width.priority = .defaultLow
        width.isActive = true
    }
}

extension TouchBarController: NSScrubberDataSource, NSScrubberDelegate, NSScrubberFlowLayoutDelegate {
extension TouchBarController: NSScrubberDataSource, NSScrubberDelegate,
                              @preconcurrency NSScrubberFlowLayoutDelegate {
    func numberOfItems(for scrubber: NSScrubber) -> Int {
        scrubber === episodeScrubber ? episodes.count : podcasts.count
    }
@@ -302,7 +296,11 @@ extension TouchBarController: NSScrubberDataSource, NSScrubberDelegate, NSScrubb
    }

    func scrubber(_ scrubber: NSScrubber, didSelectItemAt index: Int) {
        defer { scrubber.selectedIndex = -1 } // allow re-tapping the same item
        // Allow re-tapping the same item — reset after the touch settles,
        // not synchronously inside the gesture callback.
        defer {
            Task { @MainActor in scrubber.selectedIndex = -1 }
        }
        if scrubber === episodeScrubber {
            guard episodes.indices.contains(index) else { return }
            let episode = episodes[index]