FlashpointProject / launcher

Launcher for Flashpoint Archive

Home Page:https://flashpointarchive.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with extension API Game events

n0samu opened this issue · comments

Describe the bug
(Note that all functions I reference are in back/game/GameManager.ts)

The launcher's extension API's Game and Playlist events have some bugs and inconsistencies:

  • addPlaylistGame and removePlaylist do not fire any event.
  • save, updatePlaylist and updatePlaylistGame pass identical "old" and "new" objects because the object is modified without first making a copy.
    • onDidUpdateGame's oldGame and newGame both reference the new Game.
    • onDidUpdatePlaylist's oldPlaylist and newPlaylist both reference the new Playlist. This makes it impossible to detect playlist renames.
    • onDidUpdatePlaylistGame's oldGame and newGame both reference the new PlaylistGame.
  • It would be more convenient for API users if updating, adding and removing PlaylistGames fired the onDidUpdatePlaylist event.

Expected behavior
Here's how I'd personally expect the API to work:

  • Removing a Playlist should fire an onDidRemovePlaylist event.
  • Updating, adding and removing PlaylistGames should fire onDidUpdatePlaylist with the old and new Playlist object
    • For example, in the Playlist Backup extension that I'm developing, I would like to get an event whenever the user updates a playlist so I can save the updated playlist to the backup file.
  • Adding a Game/Playlist/PlaylistGame should fire the associated Update event with identical "old" and "new" objects.
  • Thus addPlaylistGame should fire both onDidUpdatePlaylist and onDidUpdatePlaylistGame.

Additional context
In the Playlist Backup extension that I'm developing, I would like to get an event whenever the user updates a playlist so I can save the updated playlist to the backup file. Some of my expectations are motivated by this.