mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-12-04 03:55:23 +03:00
Synthesize Loadout event for plugins after catch-up replay
After EDMC restarts and replays the journal during catch-up, state['Modules'] is populated from any Loadout entries in the journal. However, plugins never see these historical events — only the synthesized StartUp event is forwarded. This means plugins that depend on receiving a Loadout event (e.g. Inara's shipswap handler, Coriolis CMDR) miss the current ship loadout after an EDMC restart. Fix: after synthesizing the StartUp event, also synthesize a Loadout event via self.ship() if state['Modules'] is populated. This gives every plugin the current ship loadout on startup without requiring any plugin-side changes.
This commit is contained in:
1 parent
c25283eff9
commit
f4245a0669
1 file changed
+11
+11
@@ -409,6 +409,17 @@ class EDLogs(FileSystemEventHandler):
|
||||
|
||||
self.event_queue.put(json.dumps(entry, separators=(', ', ':')))
|
||||
|
||||
# If state['Modules'] is populated from catch-up replay (e.g. a
|
||||
# Loadout event was in the journal), synthesize a Loadout event so
|
||||
# plugins see the current ship loadout on startup. Without this,
|
||||
# plugins that wait for a Loadout event (like Inara's shipswap
|
||||
# handler) will never receive one after an EDMC restart.
|
||||
if self.state['Modules']:
|
||||
loadout_entry = self.ship(timestamped=True)
|
||||
if loadout_entry:
|
||||
logger.info("Synthesizing Loadout event for plugins (state has modules from catch-up)")
|
||||
self.event_queue.put(json.dumps(loadout_entry, separators=(', ', ':')))
|
||||
|
||||
else:
|
||||
# Generate null event to update the display (with possibly out-of-date info)
|
||||
self.event_queue.put(None)
|
||||
|
||||
Reference in new issue
Block a user