Skip to content

Commit 25cb618

Browse files
authored
Add test for svg map (#768)
1 parent d429581 commit 25cb618

2 files changed

Lines changed: 280 additions & 5 deletions

File tree

deebot_client/map.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,18 @@ async def on_minor_map(event: MinorMapEvent) -> None:
468468

469469
unsubscribers.append(self._event_bus.subscribe(MinorMapEvent, on_minor_map))
470470

471-
self._event_bus.request_refresh(CachedMapInfoEvent)
471+
async def on_cached_info(_: CachedMapInfoEvent) -> None:
472+
# We need to subscribe to it, otherwise it could happen
473+
# that the required MapSet Events are not get
474+
pass
475+
476+
cached_map_subscribers = self._event_bus.has_subscribers(CachedMapInfoEvent)
477+
unsubscribers.append(
478+
self._event_bus.subscribe(CachedMapInfoEvent, on_cached_info)
479+
)
480+
if cached_map_subscribers:
481+
# Request update only if there was already a subscriber before
482+
self._event_bus.request_refresh(CachedMapInfoEvent)
472483

473484
async def on_position(event: PositionsEvent) -> None:
474485
self._map_data.positions = event.positions

0 commit comments

Comments
 (0)