fix: closes #12618, handle missing selector

catch errors in activitypub api missing await on next()
This commit is contained in:
Barış Soner Uşaklı
2024-06-06 20:59:02 -04:00
parent 119230d7ec
commit 35eb2d0d46
4 changed files with 8 additions and 20 deletions

View File

@@ -13,18 +13,12 @@ export function init() {
template: 'admin/partials/category/selector-dropdown-right',
});
document.getElementById('site-settings').addEventListener('click', async (e) => {
const subselector = e.target.closest('[data-action]');
if (!subselector) {
return;
}
const action = subselector.getAttribute('data-action');
$('#site-settings').on('click', '[data-action]', function () {
const action = $(this).attr('data-action');
switch (action) {
case 'follow': {
const inputEl = document.getElementById('syncing.add');
const actor = inputEl.value;
const actor = $('#syncing-add').val();
put(`/categories/${ajaxify.data.cid}/follow`, { actor })
.then(ajaxify.refresh)
@@ -34,7 +28,7 @@ export function init() {
}
case 'unfollow': {
const actor = subselector.getAttribute('data-actor');
const actor = $(this).attr('data-actor');
del(`/categories/${ajaxify.data.cid}/follow`, { actor })
.then(ajaxify.refresh)

View File

@@ -42,13 +42,7 @@ Mocks.profile = async (actors) => {
} = actor;
preferredUsername = preferredUsername || slugify(name);
let hostname;
try {
({ hostname } = new URL(actor.id));
} catch (err) {
console.error(err.stack);
return null;
}
const { hostname } = new URL(actor.id);
let picture;
if (icon) {

View File

@@ -29,7 +29,7 @@ function enabledCheck(next) {
return noop;
}
next(caller, params);
await next(caller, params);
};
}

View File

@@ -52,9 +52,9 @@
{{{ end }}}
<div class="mb-3">
<label class="form-label" for="syncing.add">[[admin/manage/categories:federation.syncing-add]]</label>
<label class="form-label" for="syncing-add">[[admin/manage/categories:federation.syncing-add]]</label>
<div class="input-group">
<input id="syncing.add" type="url" class="form-control" />
<input id="syncing-add" type="url" class="form-control" />
<button data-action="follow" type="button" class="btn btn-primary">[[admin/manage/categories:federation.syncing-follow]]</button>
</div>
</div>