Skip to content

Commit aaa7580

Browse files
committed
Fix textual duplicate ids
1 parent 76d935d commit aaa7580

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

recoverpy/ui/widgets/partition_list.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from typing import Dict, Optional
44

5+
from textual import work
56
from textual.events import Mount
67
from textual.widgets import Label, ListItem, ListView
78

@@ -30,15 +31,16 @@ def _on_mount(self, _: Mount) -> None:
3031
self.set_partitions()
3132
return super()._on_mount(_)
3233

33-
def set_partitions(self, filtered: bool = True) -> None:
34-
self.clear()
34+
@work(exclusive=True)
35+
async def set_partitions(self, filtered: bool = True) -> None:
36+
await self.clear()
3537
self.list_items.clear()
3638

3739
for partition in get_partitions(filtered):
3840
log.debug(f"partition_list - Appending partition {partition.name}")
3941
list_item = self._create_list_item(partition)
4042
self.list_items[list_item.id] = partition
41-
self.append(list_item)
43+
await self.append(list_item)
4244

4345
def _create_list_item(self, partition: Partition) -> ListItem:
4446
list_item = ListItem(_get_label(partition), id=_get_partition_id(partition))

tests/integration/test_full_workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ async def test_init_app(self, pilot):
5151
for screen in pilot.app.screens:
5252
assert pilot.app.is_screen_installed(pilot.app.screens[screen])
5353
assert pilot.app.screen.name == "params"
54+
55+
await pilot.pause()
5456
assert pilot.app.screen._partition_list is not None
5557
assert (
5658
len(pilot.app.screen._partition_list.list_items) == VISIBLE_PARTITION_COUNT

0 commit comments

Comments
 (0)