mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
fix: closes #12618, handle missing selector
catch errors in activitypub api missing await on next()
This commit is contained in:
@@ -13,18 +13,12 @@ export function init() {
|
|||||||
template: 'admin/partials/category/selector-dropdown-right',
|
template: 'admin/partials/category/selector-dropdown-right',
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('site-settings').addEventListener('click', async (e) => {
|
$('#site-settings').on('click', '[data-action]', function () {
|
||||||
const subselector = e.target.closest('[data-action]');
|
const action = $(this).attr('data-action');
|
||||||
if (!subselector) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const action = subselector.getAttribute('data-action');
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'follow': {
|
case 'follow': {
|
||||||
const inputEl = document.getElementById('syncing.add');
|
const actor = $('#syncing-add').val();
|
||||||
const actor = inputEl.value;
|
|
||||||
|
|
||||||
put(`/categories/${ajaxify.data.cid}/follow`, { actor })
|
put(`/categories/${ajaxify.data.cid}/follow`, { actor })
|
||||||
.then(ajaxify.refresh)
|
.then(ajaxify.refresh)
|
||||||
@@ -34,7 +28,7 @@ export function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'unfollow': {
|
case 'unfollow': {
|
||||||
const actor = subselector.getAttribute('data-actor');
|
const actor = $(this).attr('data-actor');
|
||||||
|
|
||||||
del(`/categories/${ajaxify.data.cid}/follow`, { actor })
|
del(`/categories/${ajaxify.data.cid}/follow`, { actor })
|
||||||
.then(ajaxify.refresh)
|
.then(ajaxify.refresh)
|
||||||
|
|||||||
@@ -42,13 +42,7 @@ Mocks.profile = async (actors) => {
|
|||||||
} = actor;
|
} = actor;
|
||||||
preferredUsername = preferredUsername || slugify(name);
|
preferredUsername = preferredUsername || slugify(name);
|
||||||
|
|
||||||
let hostname;
|
const { hostname } = new URL(actor.id);
|
||||||
try {
|
|
||||||
({ hostname } = new URL(actor.id));
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err.stack);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let picture;
|
let picture;
|
||||||
if (icon) {
|
if (icon) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function enabledCheck(next) {
|
|||||||
return noop;
|
return noop;
|
||||||
}
|
}
|
||||||
|
|
||||||
next(caller, params);
|
await next(caller, params);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@
|
|||||||
{{{ end }}}
|
{{{ end }}}
|
||||||
|
|
||||||
<div class="mb-3">
|
<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">
|
<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>
|
<button data-action="follow" type="button" class="btn btn-primary">[[admin/manage/categories:federation.syncing-follow]]</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user