Skip to content

Commit 271705f

Browse files
committed
resolves #12
1 parent a588149 commit 271705f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Flitro/ContextManager.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ struct Context: Identifiable, Codable, Equatable, Hashable {
1818
var createdAt: Date = Date()
1919
var lastUsed: Date = Date()
2020

21+
/// Changes when any property relevant to UI changes.
22+
var reactiveId: Int {
23+
var hasher = Hasher()
24+
hasher.combine(id)
25+
hasher.combine(name)
26+
hasher.combine(iconName)
27+
hasher.combine(iconBackgroundColor)
28+
hasher.combine(iconForegroundColor)
29+
hasher.combine(isActive)
30+
hasher.combine(applications.count)
31+
hasher.combine(documents.count)
32+
hasher.combine(browserTabs.count)
33+
hasher.combine(terminalSessions.count)
34+
// Add more properties as needed for UI reactivity
35+
return hasher.finalize()
36+
}
37+
2138
static func == (lhs: Context, rhs: Context) -> Bool {
2239
lhs.id == rhs.id
2340
}

Flitro/FlitroApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct MenuBarExtraContents: View {
8383
}
8484
}
8585
Divider()
86-
ForEach(contextManager.contexts) { context in
86+
ForEach(contextManager.contexts, id: \.reactiveId) { context in
8787
Menu {
8888
ForEach(SwitchingMode.allCases, id: \.self) { mode in
8989
Button(mode.rawValue) {

0 commit comments

Comments
 (0)