mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
refactor bridge plugin, minor improvement to plugin tracking.
This commit is contained in:
37
plugin/src/plugin-registry.js
Normal file
37
plugin/src/plugin-registry.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// Maintains a set of known ignis plugin IDs for filtering.
|
||||
// Populated on bridge plugin load and updated when plugins are enabled/disabled.
|
||||
|
||||
const knownIds = new Set(["ignis-bridge"]);
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
const res = await fetch("/api/plugins");
|
||||
const plugins = await res.json();
|
||||
|
||||
// Keep ignis-bridge, add all bundled plugin IDs.
|
||||
knownIds.clear();
|
||||
knownIds.add("ignis-bridge");
|
||||
|
||||
for (const plugin of plugins) {
|
||||
if (plugin.bundledPluginId) {
|
||||
knownIds.add(plugin.bundledPluginId);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Keep whatever we had.
|
||||
}
|
||||
}
|
||||
|
||||
function isIgnisPlugin(pluginId) {
|
||||
return knownIds.has(pluginId);
|
||||
}
|
||||
|
||||
function addId(pluginId) {
|
||||
knownIds.add(pluginId);
|
||||
}
|
||||
|
||||
function getKnownIds() {
|
||||
return knownIds;
|
||||
}
|
||||
|
||||
module.exports = { refresh, isIgnisPlugin, addId, getKnownIds };
|
||||
Reference in New Issue
Block a user