appview/pages: swap all star buttons for same repository #834

merged
opened by boltless.me targeting master from sl/uzmtowmlwkvz

On timeline, if there is multiple cards for same repository including a star button, when user star/unstar the repository, only first #starBtn is swapped with new button.

This can be fixed by adding data-star-subject-at attr to identify all star buttons related to same repository and use hx-swap-oob to replace all of them.

Signed-off-by: Seongmin Lee git@boltless.me

Changed files
+2
appview
pages
templates
fragments
+2
appview/pages/templates/fragments/starBtn.html
···
<button
id="starBtn"
class="btn disabled:opacity-50 disabled:cursor-not-allowed flex gap-2 items-center group"
+
data-star-subject-at="{{ .SubjectAt }}"
{{ if .IsStarred }}
hx-delete="/star?subject={{ .SubjectAt }}&countHint={{ .StarCount }}"
{{ else }}
···
hx-trigger="click"
hx-target="this"
hx-swap="outerHTML"
+
hx-swap-oob='outerHTML:#starBtn[data-star-subject-at="{{ .SubjectAt }}"]'
hx-disabled-elt="#starBtn"
>
{{ if .IsStarred }}