Monorepo for Tangled tangled.org

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

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3m6ed3hgopj22
+2
Diff #0
+2
appview/pages/templates/fragments/starBtn.html
··· 2 2 <button 3 3 id="starBtn" 4 4 class="btn disabled:opacity-50 disabled:cursor-not-allowed flex gap-2 items-center group" 5 + data-star-subject-at="{{ .SubjectAt }}" 5 6 {{ if .IsStarred }} 6 7 hx-delete="/star?subject={{ .SubjectAt }}&countHint={{ .StarCount }}" 7 8 {{ else }} ··· 11 12 hx-trigger="click" 12 13 hx-target="this" 13 14 hx-swap="outerHTML" 15 + hx-swap-oob='outerHTML:#starBtn[data-star-subject-at="{{ .SubjectAt }}"]' 14 16 hx-disabled-elt="#starBtn" 15 17 > 16 18 {{ if .IsStarred }}

History

2 rounds 1 comment
sign up or login to add to the discussion
1 commit
expand
appview/pages: swap all star buttons for same repository
3/3 success
expand
expand 1 comment

This is clever, nice! Stack looks good.

pull request successfully merged
boltless.me submitted #0
1 commit
expand
appview/pages: swap all star buttons for same repository
3/3 success
expand
expand 0 comments