Skip to content

Commit

Permalink
Merge pull request #1263 from PyPlanet/feature/687
Browse files Browse the repository at this point in the history
Order in-memory map list based on server order.
  • Loading branch information
TheMaximum committed Aug 28, 2023
2 parents c814336 + e581d67 commit 713acea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyplanet/contrib/map/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ async def update_list(self, full_update=False, detach_fks=True):
Map.select().where(Map.uid << [m['uid'] for m in rows])
))

# Order the maps to match the order on the server.
ordered_uids = [m['UId'] for m in raw_list]
ordered_maps = sorted(set(maps), key=lambda m: ordered_uids.index(m.uid) if m.uid in ordered_uids else -1)

async with self.lock:
self._maps = set(maps)
self._maps = ordered_maps

# Reload locals for all maps.
# TODO: Find better way to remove this and handle it on the folders way.
Expand Down

0 comments on commit 713acea

Please sign in to comment.