diff --git a/assets/js/main.js b/assets/js/main.js
index 8d69fab6..e9f1d0e7 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -55,7 +55,7 @@ const performClap = (e) => {
const clapKey = (action) => `clap:${(new URL(action)).pathname}`;
-const addInteractions = (btn, claps) => (claps + (btn.dataset.interactions || 0));
+const addInteractions = (btn, claps) => (claps + (Number(btn.dataset.interactions) || 0))
const setClapCount = (btn, clapCount) => {
if (clapCount === 0) {
@@ -91,10 +91,10 @@ document.addEventListener("DOMContentLoaded", () => {
btn.parentElement.classList.add('clapped')
setClapCount(btn, lastClappedTo)
}
- toCheck.push(action)
+ toCheck.push([action, btn])
})
- toCheck.forEach((action) => {
+ toCheck.forEach(([action, btn]) => {
fetch(action, { method: 'GET', headers: new Headers({ 'Accept': 'application/json' }) })
.then(res => {
if (res.status !== 200) {
diff --git a/layouts/partials/claps.html b/layouts/partials/claps.html
index fd399b00..8b08c022 100644
--- a/layouts/partials/claps.html
+++ b/layouts/partials/claps.html
@@ -11,8 +11,9 @@
{{- errorf "%s" . -}}
{{- else -}}
{{- $data := .Content | transform.Unmarshal -}}
- {{- $clapCount := add $interactionCount ((index $data $relperma) | default 0) -}}
- {{- with $clapCount }}{{ . }}{{ end -}}
+ {{- $clapCount := (index $data $relperma) | default 0 -}}
+ {{- $totalCount := add (int $interactionCount) (int $clapCount) -}}
+ {{- with $totalCount }}{{ . }}{{ end -}}
{{- end -}}
{{- else -}}
{{- errorf "Unable to get all clap counts" -}}