Skip to content

Commit

Permalink
Avoid unncessary re-renders
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 19, 2023
1 parent d3bdb46 commit 6dad168
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
17 changes: 0 additions & 17 deletions lumen/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,23 +818,6 @@ def _navigate(self, event: param.parameterized.Event):

def _set_loading(self, name: str = ''):
state.loading_msg.object = f'<b>Reloading {name}...</b>'
if isinstance(self._layout, pn.GridBox):
items = [pn.pane.HTML(width=self._layout[i].width) # type: ignore
for i in range(self._layout.ncols) if i < len(self._layout)]
index = int(min(self._layout.ncols, (len(self._layout)-1)) / 2)
if items:
items[index] = self._loading
else:
items = [self._loading]
elif isinstance(self._layout, pn.Tabs):
items = list(zip(self._layout._names, list(self._layout.objects))) # type: ignore
tab_name = items[self._layout.active][0]
if name and tab_name != name:
return
items[self._layout.active] = (tab_name, self._loading)
else:
items = [self._loading]
self._layout[:] = items
self._main.loading = True

def _open_modal(self, event: param.parameterized.Event):
Expand Down
2 changes: 1 addition & 1 deletion lumen/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def _rerender(self, update_views: bool = True):
if update_views:
self._rerender_cards(cards)
rerender = True
if cards != self._cards:
if set(cards) != set(self._cards):
self._cards[:] = cards
rerender = True
if rerender:
Expand Down

0 comments on commit 6dad168

Please sign in to comment.