diff --git a/quickshell/plugins/PluginHost.qml b/quickshell/plugins/PluginHost.qml index dcf6ab5..52cdcb6 100644 --- a/quickshell/plugins/PluginHost.qml +++ b/quickshell/plugins/PluginHost.qml @@ -24,12 +24,34 @@ Scope { } readonly property var hosted: PluginService.plugins.filter(p => PluginService.isEnabled(p.id)).map(p => p.id) + // Every config write (a wallpaper change, say) rebuilds `hosted`, and an + // Instantiator handed a new array recreates all its delegates, restarting + // long-running services such as a replay buffer. Mirror it into a model + // that only changes for plugins that were actually enabled or disabled. + ListModel { + id: hostedModel + } + function syncHosted() { + for (let i = hostedModel.count - 1; i >= 0; i--) { + if (!hosted.includes(hostedModel.get(i).pluginId)) + hostedModel.remove(i); + } + const present = []; + for (let i = 0; i < hostedModel.count; i++) + present.push(hostedModel.get(i).pluginId); + for (const id of hosted) { + if (!present.includes(id)) + hostedModel.append({ pluginId: id }); + } + } + onHostedChanged: syncHosted() + Component.onCompleted: syncHosted() + Instantiator { - model: root.hosted + model: hostedModel delegate: Scope { id: slot - required property string modelData - readonly property string pluginId: modelData + required property string pluginId readonly property var kinds: PluginService.kinds(pluginId) readonly property var manifest: (PluginService.plugin(pluginId) || {}).manifest || {} readonly property bool noctalia: PluginService.ecosystem(pluginId) === "noctalia"