mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
feat: Persistent Plugins & Async Updates (#1231)
- PluginService: maintain persistent instances for Launcher plugins - AppSearchService: reuse persistent instances for queries - Added requestLauncherUpdate signal for async UI refreshes
This commit is contained in:
@@ -51,6 +51,10 @@ Item {
|
|||||||
function onPluginLoaded() { updateCategories() }
|
function onPluginLoaded() { updateCategories() }
|
||||||
function onPluginUnloaded() { updateCategories() }
|
function onPluginUnloaded() { updateCategories() }
|
||||||
function onPluginListUpdated() { updateCategories() }
|
function onPluginListUpdated() { updateCategories() }
|
||||||
|
function onRequestLauncherUpdate(pluginId) {
|
||||||
|
// Only update if we are actually looking at this plugin or in All category
|
||||||
|
updateFilteredModel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
@@ -411,26 +411,43 @@ Singleton {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const component = PluginService.pluginLauncherComponents[pluginId]
|
let instance = PluginService.pluginInstances[pluginId]
|
||||||
if (!component)
|
let isPersistent = true
|
||||||
|
|
||||||
|
if (!instance) {
|
||||||
|
const component = PluginService.pluginLauncherComponents[pluginId]
|
||||||
|
if (!component)
|
||||||
|
return []
|
||||||
|
|
||||||
|
try {
|
||||||
|
instance = component.createObject(root, {
|
||||||
|
"pluginService": PluginService
|
||||||
|
})
|
||||||
|
isPersistent = false
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("AppSearchService: Error creating temporary plugin instance", pluginId, ":", e)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!instance)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const instance = component.createObject(root, {
|
if (typeof instance.getItems === "function") {
|
||||||
"pluginService": PluginService
|
|
||||||
})
|
|
||||||
|
|
||||||
if (instance && typeof instance.getItems === "function") {
|
|
||||||
const items = instance.getItems(query || "")
|
const items = instance.getItems(query || "")
|
||||||
instance.destroy()
|
if (!isPersistent)
|
||||||
|
instance.destroy()
|
||||||
return items || []
|
return items || []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance) {
|
if (!isPersistent) {
|
||||||
instance.destroy()
|
instance.destroy()
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("AppSearchService: Error getting items from plugin", pluginId, ":", e)
|
console.warn("AppSearchService: Error getting items from plugin", pluginId, ":", e)
|
||||||
|
if (!isPersistent)
|
||||||
|
instance.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
return []
|
return []
|
||||||
@@ -440,26 +457,43 @@ Singleton {
|
|||||||
if (typeof PluginService === "undefined")
|
if (typeof PluginService === "undefined")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
const component = PluginService.pluginLauncherComponents[pluginId]
|
let instance = PluginService.pluginInstances[pluginId]
|
||||||
if (!component)
|
let isPersistent = true
|
||||||
|
|
||||||
|
if (!instance) {
|
||||||
|
const component = PluginService.pluginLauncherComponents[pluginId]
|
||||||
|
if (!component)
|
||||||
|
return false
|
||||||
|
|
||||||
|
try {
|
||||||
|
instance = component.createObject(root, {
|
||||||
|
"pluginService": PluginService
|
||||||
|
})
|
||||||
|
isPersistent = false
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("AppSearchService: Error creating temporary plugin instance for execution", pluginId, ":", e)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!instance)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const instance = component.createObject(root, {
|
if (typeof instance.executeItem === "function") {
|
||||||
"pluginService": PluginService
|
|
||||||
})
|
|
||||||
|
|
||||||
if (instance && typeof instance.executeItem === "function") {
|
|
||||||
instance.executeItem(item)
|
instance.executeItem(item)
|
||||||
instance.destroy()
|
if (!isPersistent)
|
||||||
|
instance.destroy()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance) {
|
if (!isPersistent) {
|
||||||
instance.destroy()
|
instance.destroy()
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("AppSearchService: Error executing item from plugin", pluginId, ":", e)
|
console.warn("AppSearchService: Error executing item from plugin", pluginId, ":", e)
|
||||||
|
if (!isPersistent)
|
||||||
|
instance.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ Singleton {
|
|||||||
signal pluginDataChanged(string pluginId)
|
signal pluginDataChanged(string pluginId)
|
||||||
signal pluginListUpdated
|
signal pluginListUpdated
|
||||||
signal globalVarChanged(string pluginId, string varName)
|
signal globalVarChanged(string pluginId, string varName)
|
||||||
|
signal requestLauncherUpdate(string pluginId)
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: resyncDebounce
|
id: resyncDebounce
|
||||||
@@ -286,12 +287,14 @@ Singleton {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDaemon) {
|
// MODIFICATION: Treat Launchers as persistent instances like Daemons
|
||||||
|
if (isDaemon || isLauncher) {
|
||||||
const instance = comp.createObject(root, {
|
const instance = comp.createObject(root, {
|
||||||
"pluginId": pluginId
|
"pluginId": pluginId,
|
||||||
|
"pluginService": root // Inject PluginService
|
||||||
});
|
});
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
console.error("PluginService: failed to instantiate daemon:", pluginId, comp.errorString());
|
console.error("PluginService: failed to instantiate plugin:", pluginId, comp.errorString());
|
||||||
pluginLoadFailed(pluginId, comp.errorString());
|
pluginLoadFailed(pluginId, comp.errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -299,13 +302,15 @@ Singleton {
|
|||||||
newInstances[pluginId] = instance;
|
newInstances[pluginId] = instance;
|
||||||
pluginInstances = newInstances;
|
pluginInstances = newInstances;
|
||||||
|
|
||||||
const newDaemons = Object.assign({}, pluginDaemonComponents);
|
if (isDaemon) {
|
||||||
newDaemons[pluginId] = comp;
|
const newDaemons = Object.assign({}, pluginDaemonComponents);
|
||||||
pluginDaemonComponents = newDaemons;
|
newDaemons[pluginId] = comp;
|
||||||
} else if (isLauncher) {
|
pluginDaemonComponents = newDaemons;
|
||||||
const newLaunchers = Object.assign({}, pluginLauncherComponents);
|
} else {
|
||||||
newLaunchers[pluginId] = comp;
|
const newLaunchers = Object.assign({}, pluginLauncherComponents);
|
||||||
pluginLauncherComponents = newLaunchers;
|
newLaunchers[pluginId] = comp;
|
||||||
|
pluginLauncherComponents = newLaunchers;
|
||||||
|
}
|
||||||
} else if (isDesktop) {
|
} else if (isDesktop) {
|
||||||
const newDesktop = Object.assign({}, pluginDesktopComponents);
|
const newDesktop = Object.assign({}, pluginDesktopComponents);
|
||||||
newDesktop[pluginId] = comp;
|
newDesktop[pluginId] = comp;
|
||||||
|
|||||||
Reference in New Issue
Block a user