Skip to content

Commit

Permalink
Ensure ntie refresh requests never start before get_events is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
podliashanyk committed Jun 21, 2024
1 parent ea1722f commit 1a16544
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/howitz/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def auth():
def get_events():
table_events = get_current_events()

return render_template('components/table/dynamic-table-body.html', event_list=table_events, refresh_interval=current_app.howitz_config["refresh_interval"])
return render_template('components/table/events-table-body.html', event_list=table_events, refresh_interval=current_app.howitz_config["refresh_interval"])


@main.route('/refresh_events')
Expand Down
11 changes: 11 additions & 0 deletions src/howitz/templates/components/table/events-table-body.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<tbody
id="eventlist-list"
hx-get="/refresh_events"
hx-swap="afterbegin"
hx-target="#eventlist-list"
hx-trigger="every {{ refresh_interval }}s"
>
{% with event_list=event_list %}
{% include "/components/table/event-rows.html" %}
{% endwith %}
</tbody>
6 changes: 1 addition & 5 deletions src/howitz/templates/components/table/events-table.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table
class="border-collapse border border-slate-500 w-full text-sm text-left text-gray-400 table-auto"
hx-get="/get_events"
hx-swap="innerHTML"
hx-swap="outerHTML"
hx-target="#eventlist-list"
hx-trigger="load"
>
Expand All @@ -21,10 +21,6 @@
</thead>
<tbody
id="eventlist-list"
hx-get="/refresh_events"
hx-swap="afterbegin"
hx-target="#eventlist-list"
hx-trigger="every {{ refresh_interval }}s"
>
{% for n in range(30) %}
{% include "/components/row/table-row-skeleton.html" %}
Expand Down

0 comments on commit 1a16544

Please sign in to comment.