Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 2ac656d

Browse files
committed
clear the image cache when the data is updated
1 parent 3302d62 commit 2ac656d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Marlin/Marlin/Networking/MSI.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,27 @@ public class MSI {
8383
let dataSource = self.masterDataList.first { type in
8484
item.key == type.key
8585
}
86-
86+
if let mapImageDataSource = dataSource as? (any MapImage) {
87+
type(of: mapImageDataSource).imageCache.clearCache()
88+
}
8789
dataSource?.postProcess()
8890
}
8991
.store(in: &cancellable)
92+
93+
NotificationCenter.default.publisher(for: .DataSourceProcessed)
94+
.receive(on: RunLoop.main)
95+
.compactMap {
96+
$0.object as? DataSourceUpdatedNotification
97+
}
98+
.sink { item in
99+
let dataSource = self.masterDataList.first { type in
100+
item.key == type.key
101+
}
102+
if let mapImageDataSource = dataSource as? (any MapImage) {
103+
type(of: mapImageDataSource).imageCache.clearCache()
104+
}
105+
}
106+
.store(in: &cancellable)
90107
}
91108

92109
func registerBackgroundHandler() {

0 commit comments

Comments
 (0)