Repository: lutris/lutris

Issue:
Library is not refreshed after a new game is installed
### Bug description

If you install a new game (I used #1 "A Test" installer), the library does not refresh to show a new entry in the library.
The new game only shows up if I switch between different tabs, "Games" and "Recent", for example.


### How to Reproduce

Steps to reproduce the behavior:
1. Install a new game
2. Finish installation
3. Check library after that
4. Switch between different tabs, "Games" and "Recent", for example
5. Game now shows up

### Expected behavior

I expect that the game shows up in the library immediately after installation and is sorted in proper order

### Log output

```shell
INFO     2022-02-12 04:23:24,639 [startup.init_lutris:162]:Starting Lutris 0.5.10
INFO     2022-02-12 04:23:24,697 [startup.check_driver:55]:Using NVIDIA drivers 510.47.03 for x86_64
INFO     2022-02-12 04:23:24,697 [startup.check_driver:59]:GPU: Unknown
INFO     2022-02-12 04:23:24,697 [startup.check_driver:75]:GPU: 10DE:1B81 1458:3772 (nvidia drivers)
DEBUG    2022-02-12 04:23:24,728 [http.get:83]:GET https://lutris.net/api/runtimes?enabled=1
DEBUG    2022-02-12 04:23:25,131 [http.get:83]:GET https://lutris.net/api/runtimes/icons
DEBUG    2022-02-12 04:23:25,309 [http.get:83]:GET https://api.github.com/repos/lutris/dxvk/releases
DEBUG    2022-02-12 04:23:25,615 [http.write_to_file:134]:Writing to /home/alex/.local/share/lutris/runtime/dxvk/dxvk_versions.json
DEBUG    2022-02-12 04:23:25,616 [http.get:83]:GET https://api.github.com/repos/lutris/dxvk-nvapi/releases
DEBUG    2022-02-12 04:23:25,830 [http.write_to_file:134]:Writing to /home/alex/.local/share/lutris/runtime/dxvk-nvapi/dxvk-nvapi_versions.json
DEBUG    2022-02-12 04:23:25,831 [http.get:83]:GET https://api.github.com/repos/lutris/vkd3d/releases
DEBUG    2022-02-12 04:23:26,037 [http.write_to_file:134]:Writing to /home/alex/.local/share/lutris/runtime/vkd3d/vkd3d_versions.json
DEBUG    2022-02-12 04:23:26,038 [http.get:83]:GET https://api.github.com/repos/lutris/d3d_extras/releases
DEBUG    2022-02-12 04:23:26,194 [http.write_to_file:134]:Writing to /home/alex/.local/share/lutris/runtime/d3d_extras/d3d_extras_versions.json
DEBUG    2022-02-12 04:23:26,195 [http.get:83]:GET https://api.github.com/repos/lutris/dgvoodoo2/releases
DEBUG    2022-02-12 04:23:26,486 [http.write_to_file:134]:Writing to /home/alex/.local/share/lutris/runtime/dgvoodoo2/dgvoodoo2_versions.json
INFO     2022-02-12 04:23:26,487 [startup.update_runtime:190]:Startup complete
DEBUG    2022-02-12 04:23:26,610 [lutriswindow.update_store:431]:Showing 21 games
DEBUG    2022-02-12 04:33:58,604 [api.get_game_installers:162]:Fetching installer https://lutris.net/api/installers/test
DEBUG    2022-02-12 04:33:58,605 [http.get:83]:GET https://lutris.net/api/installers/test
DEBUG    2022-02-12 04:33:59,095 [application.show_window:268]:Showing window InstallerWindowtest
DEBUG    2022-02-12 04:34:01,742 [lutriswindow.update_store:431]:Showing 20 games
DEBUG    2022-02-12 04:34:08,603 [displayconfig.get_current_resolution:624]:Retrieving current resolution
INFO     2022-02-12 04:34:11,240 [runner.get_runner_version:323]:Getting runner information for wine
DEBUG    2022-02-12 04:34:11,240 [http.get:83]:GET https://lutris.net/api/runners/wine
DEBUG    2022-02-12 04:34:11,460 [interpreter.get_runners_to_install:217]:Default wine version is lutris-fshack-6.21-6
DEBUG    2022-02-12 04:34:11,464 [installerwindow.on_runners_ready:310]:Installer doesn't require files
DEBUG    2022-02-12 04:34:11,465 [interpreter._iter_commands:306]:Installer command: {'task': {'arch': 'win64', 'name': 'create_prefix', 'prefix': '$GAMEDIR'}}
INFO     2022-02-12 04:34:11,466 [wine.create_prefix:96]:Creating a win64 prefix in /home/alex/Games/test1
DEBUG    2022-02-12 04:34:11,467 [system.execute:50]:Executing /home/alex/.local/share/lutris/runners/wine/lutris-fshack-6.21-6-x86_64/bin/wineboot
DEBUG    2022-02-12 04:34:11,467 [system.execute:56]:WINEARCH=win64 WINEPREFIX=/home/alex/Games/test1 WINEDLLOVERRIDES=winemenubuilder=
INFO     2022-02-12 04:34:30,156 [wine.create_prefix:143]:win64 Prefix created in /home/alex/Games/test1
DEBUG    2022-02-12 04:34:30,194 [config.write_game_config:26]:Writing game config to /home/alex/.config/lutris/games/a-test-1-test-1644629670.yml
DEBUG    2022-02-12 04:34:30,204 [http.get:83]:GET https://lutris.net/api/games/test
DEBUG    2022-02-12 04:34:30,642 [game.save:257]:Saving A test (wine) with config ID a-test-1-test-1644629670
DEBUG    2022-02-12 04:34:30,682 [lutriswindow.on_game_updated:779]:Game A test (wine) not updated in view
DEBUG    2022-02-12 04:34:49,790 [system.remove_folder:223]:Removing folder /home/alex/.cache/lutris/installer/test
DEBUG    2022-02-12 04:34:49,790 [application.on_app_window_destroyed:285]:Removed window InstallerWindowtest
```


### System Information

```shell
[System]
OS:              Arch Linux rolling n/a
Arch:            x86_64
Kernel:          5.16.3-241-tkg-pds
Desktop:         GNOME
Display Server:  x11

[CPU]
Vendor:          AuthenticAMD
Model:           AMD Ryzen 7 3800X 8-Core Processor
Physical cores:  8
Logical cores:   16

[Memory]
RAM:             31.3 GB
Swap:            1.9 GB

[Graphics]
Vendor:          NVIDIA Corporation
OpenGL Renderer: NVIDIA GeForce GTX 1070/PCIe/SSE2
OpenGL Version:  4.6.0 NVIDIA 510.47.03
OpenGL Core:     4.6.0 NVIDIA 510.47.03
OpenGL ES:       OpenGL ES 3.2 NVIDIA 510.47.03
Vulkan:          Supported
```


### Media (optional)

_No response_

### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:
This appears to be a regression so tagging for 0.5.10
same as this? https://github.com/lutris/lutris/issues/4045
Sounds like it. Which one should I close? I think mine is a little bit more detailed

Resolving patch:
diff --git a/lutris/gui/lutriswindow.py b/lutris/gui/lutriswindow.py
--- a/lutris/gui/lutriswindow.py
+++ b/lutris/gui/lutriswindow.py
@@ -776,7 +776,7 @@ def on_game_updated(self, game):
             return True
         updated = self.game_store.update(db_game)
         if not updated:
-            logger.debug("Game %s not updated in view", game)
+            self.update_store()
         return True
 
     def on_game_stopped(self, game):
diff --git a/lutris/gui/views/store.py b/lutris/gui/views/store.py
--- a/lutris/gui/views/store.py
+++ b/lutris/gui/views/store.py
@@ -121,7 +121,8 @@ def remove_game(self, _id):
 
     def update(self, db_game):
         """Update game informations
-        Return whether a row was updated
+        Return whether a row was updated; False if the game was not already
+        present.
         """
         store_item = StoreItem(db_game, self.service_media)
         row = self.get_row_by_id(store_item.id)


Test patch: