@@ -49,6 +49,8 @@ private func getAutoAddIms(_ plugin: String) -> [String] {
4949class PluginVM : ObservableObject {
5050 @Published private( set) var installedPlugins = [ Plugin] ( )
5151 @Published private( set) var availablePlugins = [ Plugin] ( )
52+ @Published var nativeAvailable = [ String] ( )
53+ @Published var dataAvailable = [ String] ( )
5254 @Published var upToDate = false
5355
5456 func refreshPlugins( ) {
@@ -110,9 +112,6 @@ struct PluginView: View {
110112 @State private var selectedInstalled = Set < String > ( )
111113 @State private var selectedAvailable = Set < String > ( )
112114
113- @State private var nativeAvailable = [ String] ( )
114- @State private var dataAvailable = [ String] ( )
115-
116115 @State private var processing = false
117116 @State private var promptRestart = false
118117
@@ -140,8 +139,8 @@ struct PluginView: View {
140139 showCheckFailed = true
141140 return
142141 }
143- nativeAvailable = nativePlugins
144- dataAvailable = dataPlugins
142+ pluginVM . nativeAvailable = nativePlugins
143+ pluginVM . dataAvailable = dataPlugins
145144 if nativePlugins. isEmpty && dataPlugins. isEmpty {
146145 pluginVM. upToDate = true
147146 showUpToDate = true
@@ -198,8 +197,8 @@ struct PluginView: View {
198197 processing = true
199198
200199 if !isUpdate {
201- nativeAvailable. removeAll ( )
202- dataAvailable. removeAll ( )
200+ pluginVM . nativeAvailable. removeAll ( )
201+ pluginVM . dataAvailable. removeAll ( )
203202
204203 var countedPlugins = Set < String > ( )
205204 func helper( _ plugin: String ) {
@@ -210,10 +209,10 @@ struct PluginView: View {
210209 // Skip installed dependencies.
211210 if let info = pluginMap [ plugin] , !pluginVM. installedPlugins. contains ( info) {
212211 if info. native {
213- nativeAvailable. append ( plugin)
212+ pluginVM . nativeAvailable. append ( plugin)
214213 }
215214 // Assumption: all official plugins contain a data tarball.
216- dataAvailable. append ( plugin)
215+ pluginVM . dataAvailable. append ( plugin)
217216 for dependency in info. dependencies {
218217 helper ( dependency)
219218 }
@@ -227,7 +226,7 @@ struct PluginView: View {
227226 selectedAvailable. removeAll ( )
228227
229228 let updater = Updater (
230- main: false , debug: false , nativePlugins: nativeAvailable, dataPlugins: dataAvailable)
229+ main: false , debug: false , nativePlugins: pluginVM . nativeAvailable, dataPlugins: pluginVM . dataAvailable)
231230 updater. update (
232231 onFinish: { _, nativeResults, dataResults in
233232 processing = false
@@ -301,7 +300,7 @@ struct PluginView: View {
301300
302301 Spacer ( ) . frame ( height: gapSize)
303302
304- ForEach ( Set ( nativeAvailable) . union ( dataAvailable) . sorted ( ) , id: \. self) {
303+ ForEach ( Set ( pluginVM . nativeAvailable) . union ( pluginVM . dataAvailable) . sorted ( ) , id: \. self) {
305304 plugin in
306305 Text ( plugin)
307306 }
0 commit comments