Skip to content

Commit 6cd4604

Browse files
fix(ui): isolate folder glyph caches to the main actor
1 parent 8c7bf44 commit 6cd4604

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎App/FileMint/DesignSystem.swift‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ enum FileMintStyle {
8888
}
8989

9090
private typealias FolderColors = (tab: NSColor, top: NSColor, bottom: NSColor, edge: NSColor)
91-
static let folderGlyph = drawFolder {
91+
@MainActor static let folderGlyph = drawFolder {
9292
(srgbColor(0x779F89), srgbColor(0xB7D0BF), srgbColor(0x88AD98), srgbColor(0x6F9681).withAlphaComponent(0.55))
9393
}
9494

@@ -130,12 +130,12 @@ enum FileMintStyle {
130130
}
131131
}
132132

133-
struct FileMintPalette {
133+
final class FileMintPalette: Sendable {
134134
let accentNS: NSColor
135135
let selectionNS: NSColor
136136
let strongNS: NSColor
137137
let onStrongNS: NSColor
138-
let folderGlyph: NSImage
138+
@MainActor private(set) lazy var folderGlyph = FileMintStyle.folderGlyph(accent: accentNS, selection: selectionNS)
139139

140140
var accent: Color { Color(nsColor: accentNS) }
141141
var selection: Color { Color(nsColor: selectionNS) }
@@ -148,10 +148,9 @@ struct FileMintPalette {
148148
selectionNS = FileMintStyle.adaptive(selection.0, selection.1)
149149
strongNS = FileMintStyle.adaptive(strong.0, strong.1)
150150
onStrongNS = FileMintStyle.adaptive(0xFFFFFF, onStrongDark)
151-
folderGlyph = FileMintStyle.folderGlyph(accent: accentNS, selection: selectionNS)
152151
}
153152

154-
private init(rgb: UInt32) {
153+
private convenience init(rgb: UInt32) {
155154
let light = AppAccentPalette(rgb: rgb, dark: false)
156155
let dark = AppAccentPalette(rgb: rgb, dark: true)
157156
self.init(accent: (light.accent, dark.accent), selection: (light.selection, dark.selection),

0 commit comments

Comments
 (0)