Skip to content

Commit 1ce980f

Browse files
committed
fix early return to fix reload issue
1 parent 8c4a74c commit 1ce980f

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

NetworkDynamicsInspector/src/timeseries.jl

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,42 @@ function timeseries_cards(app, session)
5252
known_tsplots = collect(keys(cache))
5353
current_tsplots = collect(values(_tsplots))
5454

55-
# do nothing if the TSPlots objects themselve did not change
56-
Set(known_tsplots) == Set(current_tsplots) && return
57-
58-
# del_tsplots = setdiff(known_tsplots, current_tsplots)
59-
# new_tsplots = setdiff(current_tsplots, known_tsplots)
60-
# FIXME: it is not possible to redisplay the same tsplot, recreate all
61-
del_tsplots = known_tsplots
62-
new_tsplots = current_tsplots
63-
64-
for del in del_tsplots
65-
(; card, observerfunctions, plotqueue) = cache[del]
66-
close(plotqueue) # close plotqueue
67-
Observables.off.(observerfunctions) # disable all observer functions
68-
delete!(cache, del) # delete from cache
69-
end
70-
for new in new_tsplots
71-
key = only([key for (key, value) in _tsplots if value == new])
72-
ntup = timeseries_card(app, key, session)
73-
cache[new] = ntup
74-
end
55+
# do nothing if the TSPlots objects themselve did not change unless on update!
56+
if !isdefined(container, 0) || Set(known_tsplots) != Set(current_tsplots)
57+
# del_tsplots = setdiff(known_tsplots, current_tsplots)
58+
# new_tsplots = setdiff(current_tsplots, known_tsplots)
59+
# FIXME: it is not possible to redisplay the same tsplot, recreate all
60+
del_tsplots = known_tsplots
61+
new_tsplots = current_tsplots
62+
63+
for del in del_tsplots
64+
(; card, observerfunctions, plotqueue) = cache[del]
65+
close(plotqueue) # close plotqueue
66+
Observables.off.(observerfunctions) # disable all observer functions
67+
delete!(cache, del) # delete from cache
68+
end
69+
for new in new_tsplots
70+
key = only([key for (key, value) in _tsplots if value == new])
71+
ntup = timeseries_card(app, key, session)
72+
cache[new] = ntup
73+
end
7574

76-
cards = [cache[ts].card for ts in values(_tsplots)]
77-
# update the display by notifying the content
78-
container[] = DOM.div(cards; class="timeseries-stack")
75+
cards = [cache[ts].card for ts in values(_tsplots)]
76+
# update the display by notifying the content
77+
container[] = DOM.div(cards; class="timeseries-stack")
78+
end
7979

8080
nothing
8181
end
8282

8383
# update the selected components in the graphplot when the active tsplot changes
8484
on(app.active_tsplot; update=true) do active
85-
activesel = app.tsplots[][active].selcomp[]
86-
app.graphplot._selcomp[] = activesel
85+
if haskey(app.tsplots[], active)
86+
activesel = app.tsplots[][active].selcomp[]
87+
app.graphplot._selcomp[] = activesel
88+
else
89+
app.active_tsplot[] = first(keys(app.tsplots[]))
90+
end
8791
end
8892

8993
return container

0 commit comments

Comments
 (0)