diff --git a/apps/git/index.tsx b/apps/git/index.tsx index 076d971..54c958a 100644 --- a/apps/git/index.tsx +++ b/apps/git/index.tsx @@ -23,12 +23,15 @@ function toggleVisibility(btn) { var next = current === 'public' ? 'private' : 'public'; btn.dataset.visibility = next; btn.textContent = next; - btn.className = btn.className.replace(' public', ''); - if (next === 'public') btn.className += ' public'; + btn.classList.toggle('public', next === 'public'); fetch('/api/visibility/' + encodeURIComponent(repo), { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ visibility: next }) + }).catch(function() { + btn.dataset.visibility = current; + btn.textContent = current; + btn.classList.toggle('public', current === 'public'); }); } `