Skip to content

Commit

Permalink
refactor(image-list): reuse AbstractElement state+ctrl
Browse files Browse the repository at this point in the history
Guard against double call to init_visibile_columns
  • Loading branch information
PaulHax committed Oct 17, 2024
1 parent 51b9fdf commit 0d42b9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/nrtk_explorer/app/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def apply_ui(self):
self._parameters_app.transform_apply_ui()

def dataset_widget(self):
ImageList(self.server, self.on_scroll, self.on_hover)
ImageList(self.on_scroll, self.on_hover)

# This is only used within when this module (file) is executed as an Standalone app.
@property
Expand Down
12 changes: 7 additions & 5 deletions src/nrtk_explorer/app/ui/image_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ def column_toggler(old_columns, new_columns):
"original_detection_to_transformed_detection_score",
]

visibile_columns_initialized = False


def init_visibile_columns(state):
global visibile_columns_initialized
if visibile_columns_initialized:
return
state.visible_columns = [col["name"] for col in COLUMNS]
make_dependent_columns_handler(state, ORIGINAL_COLUMNS)
make_dependent_columns_handler(state, TRANSFORM_COLUMNS)
visibile_columns_initialized = True


class ImageWithSpinner(html.Div):
Expand Down Expand Up @@ -147,12 +153,8 @@ def update_pagination(self, **kwargs):
else:
self.state.pagination = {**old_pagination, "rowsPerPage": 0} # show all rows

def __init__(self, server, on_scroll, on_hover, **kwargs):
def __init__(self, on_scroll, on_hover, **kwargs):
super().__init__(classes="full-height", **kwargs)
self.server = server
self.state = server.state
self.ctrl = server.controller

self.visible_ids = set()
self.scroll_callback = on_scroll
self.update_pagination()
Expand Down

0 comments on commit 0d42b9e

Please sign in to comment.