Merge branch 'dev' into immediate-finds

This commit is contained in:
Nuckyz 2024-05-07 02:49:24 -03:00
commit b047f9ce28
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -36,6 +36,7 @@ export const patches = [] as Patch[];
/** Whether we have subscribed to flux events of all the enabled plugins when FluxDispatcher was ready */ /** Whether we have subscribed to flux events of all the enabled plugins when FluxDispatcher was ready */
let enabledPluginsSubscribedFlux = false; let enabledPluginsSubscribedFlux = false;
const subscribedFluxEventsPlugins = new Set<string>();
const settings = Settings.plugins; const settings = Settings.plugins;
@ -123,7 +124,9 @@ export function startDependenciesRecursive(p: Plugin) {
} }
export function subscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) { export function subscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) {
if (p.flux) { if (p.flux && !subscribedFluxEventsPlugins.has(p.name)) {
subscribedFluxEventsPlugins.add(p.name);
logger.debug("Subscribing to flux events of plugin", p.name); logger.debug("Subscribing to flux events of plugin", p.name);
for (const [event, handler] of Object.entries(p.flux)) { for (const [event, handler] of Object.entries(p.flux)) {
fluxDispatcher.subscribe(event as FluxEvents, handler); fluxDispatcher.subscribe(event as FluxEvents, handler);
@ -133,6 +136,8 @@ export function subscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof Flux
export function unsubscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) { export function unsubscribePluginFluxEvents(p: Plugin, fluxDispatcher: typeof FluxDispatcher) {
if (p.flux) { if (p.flux) {
subscribedFluxEventsPlugins.delete(p.name);
logger.debug("Unsubscribing from flux events of plugin", p.name); logger.debug("Unsubscribing from flux events of plugin", p.name);
for (const [event, handler] of Object.entries(p.flux)) { for (const [event, handler] of Object.entries(p.flux)) {
fluxDispatcher.unsubscribe(event as FluxEvents, handler); fluxDispatcher.unsubscribe(event as FluxEvents, handler);