fix: closes #13078, toggle /world navItem when AP is toggled

This commit is contained in:
Barış Soner Uşaklı
2025-03-08 00:09:41 -05:00
parent c83f91bd12
commit bef1792086
2 changed files with 21 additions and 0 deletions

View File

@@ -132,6 +132,7 @@ Configs.setMultiple = async function (data) {
await processConfig(data);
data = serialize(data);
await db.setObject('config', data);
await updateNavItems(data);
updateConfig(deserialize(data));
};
@@ -228,6 +229,13 @@ async function getLogoSize(data) {
data['brand:emailLogo:width'] = size.width;
}
async function updateNavItems(data) {
if (data.hasOwnProperty('activitypubEnabled')) {
const navAdmin = require('../navigation/admin');
await navAdmin.update('/world', { enabled: data.activitypubEnabled ? 'on' : '' });
}
}
function updateConfig(config) {
updateLocalConfig(config);
pubsub.publish('config:update', config);

View File

@@ -85,6 +85,19 @@ admin.get = async function () {
return cache.map(item => ({ ...item }));
};
admin.update = async function (route, data) {
const ids = await db.getSortedSetRange('navigation:enabled', 0, -1);
const navItems = await db.getObjects(ids.map(id => `navigation:enabled:${id}`));
const matchedRoutes = navItems.filter(item => item && item.route === route);
if (matchedRoutes.length) {
await db.setObjectBulk(
matchedRoutes.map(item => [`navigation:enabled:${item.order}`, data])
);
cache = null;
pubsub.publish('admin:navigation:save');
}
};
async function getAvailable() {
const core = require('../../install/data/navigation.json').map((item) => {
item.core = true;