mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-10 01:23:04 +01:00
fix: closes #13078, toggle /world navItem when AP is toggled
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user