Changeset 6c152a5 in Klonkt for src/assets
- Timestamp:
- 07/28/2026 08:15:31 PM (6 weeks ago)
- Branches:
- main
- Children:
- 6eab7e9
- Parents:
- 742ba7e
- File:
-
- 1 edited
-
src/assets/js/guardian.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/js/guardian.js
r742ba7e r6c152a5 203 203 else if (check.last === false) box.appendChild(el('p', null, T.release_step_down || '')); 204 204 else box.appendChild(el('p', 'grave', T.release_unknown || '')); 205 if (check.federates === false)box.appendChild(el('p', null, T.release_local || ''));205 box.appendChild(el('p', null, T.release_local || '')); 206 206 207 207 var row = el('div', 'row'); 208 var yes = el('button', 'danger small', T.release_yes || 'Yes');209 yes.addEventListener('click', function () { yes.disabled = true; remove(uri, yes); });210 208 var no = el('button', 'small', T.release_no || 'No'); 211 209 no.addEventListener('click', function () { … … 214 212 }); 215 213 // No first: the way out should be the easy one to hit. 216 row.appendChild(no); row.appendChild(yes); 214 row.appendChild(no); 215 // Being the last guardian is not a warning but a wall: the server refuses 216 // it (§3.4), so offering a yes here would only produce an error. The text 217 // above already says what has to happen instead. 218 if (check.last !== true) { 219 var yes = el('button', 'danger small', T.release_yes || 'Yes'); 220 yes.addEventListener('click', function () { 221 yes.disabled = true; 222 remove(uri, yes, function (err) { 223 // The guardian set can change between the check and the click. 224 yes.disabled = false; 225 box.appendChild(el('p', 'grave', err === 'would_emancipate' ? (T.release_last || '') : (T.failed || ''))); 226 if (err === 'would_emancipate') yes.remove(); 227 }); 228 }); 229 row.appendChild(yes); 230 } 217 231 box.appendChild(row); 218 232 return box; … … 312 326 } 313 327 314 function remove(uri, btn ) {328 function remove(uri, btn, onError) { 315 329 btn.disabled = true; 316 330 fetch('/guardian/wards/remove', { 317 331 method: 'POST', headers: { 'Content-Type': 'application/json' }, 318 332 body: JSON.stringify({ uri: uri, site: S.site }), 319 }).then(refresh); 333 }).then(function (r) { return r.json().then(function (j) { return { ok: r.ok, j: j }; }); }) 334 .then(function (res) { 335 // The server can refuse: emptying shaer:guardians is emancipation and 336 // not one guardian's call (§3.4). Say so instead of silently redrawing. 337 if (!res.ok) { if (onError) onError(res.j && res.j.error); return; } 338 refresh(); 339 }) 340 .catch(function () { if (onError) onError('network'); else btn.disabled = false; }); 320 341 } 321 342
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)