Fixed mastodon checkbox on new entry page
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
const commentInput = document.getElementById('comment-input');
|
||||
const newTagsInput = document.getElementById('new-tags-input');
|
||||
const existingTagsEl = document.getElementById('existing-tags');
|
||||
const mastodonPublishing = document.getElementById('mastodon-publishing');
|
||||
const mastodonEnabledCheckbox = document.getElementById('mastodon-enabled');
|
||||
const scrapeButton = document.getElementById('scrape-button');
|
||||
const scrapeStatus = document.getElementById('scrape-status');
|
||||
@@ -46,7 +47,7 @@
|
||||
.then((user) => {
|
||||
currentUser = user;
|
||||
entryForm.classList.remove('hidden');
|
||||
loadTags();
|
||||
Promise.all([loadTags(), loadMastodonPublishing()]);
|
||||
})
|
||||
.catch(() => {
|
||||
localStorage.removeItem('linklogAccessToken');
|
||||
@@ -66,6 +67,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMastodonPublishing() {
|
||||
try {
|
||||
const response = await fetch('/api/user/plugins/mastodon', {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!response.ok) return;
|
||||
const config = await response.json();
|
||||
mastodonEnabledCheckbox.checked = Boolean(config.configured);
|
||||
mastodonPublishing.classList.toggle('hidden', !config.configured);
|
||||
} catch (error) {
|
||||
console.error('Could not load Mastodon configuration:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Render tag checkboxes
|
||||
function renderTags() {
|
||||
existingTagsEl.innerHTML = '';
|
||||
@@ -171,6 +186,7 @@
|
||||
url,
|
||||
comment,
|
||||
tags,
|
||||
post_to_mastodon: mastodonEnabledCheckbox.checked,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user