Changeset 5c373b8 in Klonkt for src/assets
- Timestamp:
- 07/25/2026 07:51:28 AM (7 weeks ago)
- Branches:
- main
- Children:
- e62f65d
- Parents:
- 28267519
- File:
-
- 1 edited
-
src/assets/js/guardian2.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/js/guardian2.js
r28267519 r5c373b8 165 165 } 166 166 167 // ── 0b. Follow requests on your wards (§5.3) ──────────────────────────── 168 function answerFollow(id, decision, btn) { 169 if (btn) btn.disabled = true; 170 fetch('/guardian2/api/follow/' + encodeURIComponent(id), { 171 method: 'POST', headers: { 'Content-Type': 'application/json' }, 172 body: JSON.stringify({ decision: decision, site: S.site }), 173 }).then(loadFollowReqs); 174 } 175 function renderFollowReqs(items) { 176 var list = document.getElementById('follow-list'); 177 list.textContent = ''; 178 (items || []).forEach(function (f) { 179 var card = el('div', 'g-card'); 180 var row = el('div', 'row'); 181 row.appendChild(el('span', 'who grow', f.follower + ' → @' + f.ward)); 182 var ok = el('button', 'small', T.accept || 'Accept'); 183 ok.addEventListener('click', function () { answerFollow(f.id, 'approve', ok); }); 184 var no = el('button', 'quiet small', T.reject || 'Deny'); 185 no.addEventListener('click', function () { answerFollow(f.id, 'reject', no); }); 186 row.appendChild(ok); row.appendChild(no); 187 card.appendChild(row); 188 list.appendChild(card); 189 }); 190 show('follow-section', (items || []).length > 0); 191 } 192 function loadFollowReqs() { 193 return fetch('/guardian2/api/follow-requests?site=' + encodeURIComponent(S.site)) 194 .then(function (r) { return r.json(); }) 195 .then(function (f) { if (f && !f.error) renderFollowReqs(f.items); }) 196 .catch(function () { /* stays hidden */ }); 197 } 198 167 199 function refresh() { 168 200 return fetch('/guardian2/api/state?site=' + encodeURIComponent(S.site)) 169 201 .then(function (r) { return r.json(); }) 170 202 .then(function (s) { if (s && !s.error) { S = s; T = s.strings || T; renderAll(); } }) 171 .then(loadFeed) ;203 .then(loadFeed).then(loadFollowReqs); 172 204 } 173 205 … … 263 295 }); 264 296 265 renderAll(); pushState(); loadFeed(); 297 renderAll(); pushState(); loadFeed(); loadFollowReqs(); 266 298 setInterval(refresh, 45000); // live-ish while open 267 299 } catch (e) {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)