Only triggere a game select state change when the selection actually changes
This commit is contained in:
1 parent
1f43702839
commit
1134dfcef3
1 file changed
+5
-7
@@ -250,10 +250,6 @@ class GameSelector:
|
|||||||
self._games: OrderedDict[str, Game] = OrderedDict()
|
self._games: OrderedDict[str, Game] = OrderedDict()
|
||||||
self._list.bind("<<ListboxSelect>>", self._on_select)
|
self._list.bind("<<ListboxSelect>>", self._on_select)
|
||||||
|
|
||||||
@property
|
|
||||||
def selected(self) -> Optional[str]:
|
|
||||||
return self._selection
|
|
||||||
|
|
||||||
def set_games(self, games: Iterable[Game]):
|
def set_games(self, games: Iterable[Game]):
|
||||||
self._games.clear()
|
self._games.clear()
|
||||||
self._games.update((str(g), g) for g in sorted(games, key=lambda g: g.name))
|
self._games.update((str(g), g) for g in sorted(games, key=lambda g: g.name))
|
||||||
@@ -280,10 +276,12 @@ class GameSelector:
|
|||||||
current = self._list.curselection()
|
current = self._list.curselection()
|
||||||
if not current:
|
if not current:
|
||||||
# can happen when the user clicks on an empty list
|
# can happen when the user clicks on an empty list
|
||||||
self._selection = None
|
new_selection = None
|
||||||
else:
|
else:
|
||||||
self._selection = self._list.get(current[0])
|
new_selection = self._list.get(current[0])
|
||||||
self._manager._twitch.change_state(State.GAME_SELECT)
|
if new_selection != self._selection:
|
||||||
|
self._selection = new_selection
|
||||||
|
self._manager._twitch.change_state(State.GAME_SELECT)
|
||||||
|
|
||||||
def get_selection(self) -> Game:
|
def get_selection(self) -> Game:
|
||||||
if self._selection is None:
|
if self._selection is None:
|
||||||
|
|||||||
Reference in new issue
Block a user