Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions modules/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ async def add_games(*threads: list[ThreadMatch | SearchResult]):
async def _add_games():
dupes = []
added = []
games = []
for thread in threads:
if thread.id in globals.games:
dupes.append(globals.games[thread.id].name)
Expand All @@ -553,18 +554,20 @@ async def _add_games():
await db.load_games(thread.id)
game = globals.games[thread.id]
added.append(game.name)
games.append(game)
if globals.settings.mark_installed_after_add:
game.installed = game.version
if globals.settings.select_executable_after_add:
add_game_exe(game)
dupe_count = len(dupes)
added_count = len(added)
if len(games) > 0:
await api.refresh(*games, full=True, notifs=False)
if dupe_count > 0 or added_count > 1:
utils.push_popup(
msgbox.msgbox, f"{'Duplicate' if dupe_count > 0 else 'Added'} games",
(
(f"{added_count} new game{' has' if added_count == 1 else 's have'} been added to your library.\n"
"Make sure to refresh to grab all the game details.")
(f"{added_count} new game{' has' if added_count == 1 else 's have'} been added to your library.")
if added_count > 0 else ""
) +
("\n\n" if dupe_count > 0 and added_count > 0 else "") +
Expand All @@ -573,7 +576,7 @@ async def _add_games():
if dupe_count > 0 else ""
),
MsgBox.warn if dupe_count > 0 else MsgBox.info,
more=(("Added:\n - " + "\n - ".join(added)) if added_count > 0 else "") +
more=(("Added:\n - " + "\n - ".join(game.name for game in games)) if added_count > 0 else "") +
("\n\n" if dupe_count > 0 and added_count > 0 else "") +
(("Duplicates:\n - " + "\n - ".join(dupes)) if dupe_count > 0 else "")
)
Expand Down