mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
Support for using yarn instead of npm, include unread counts on cold load (#6179)
* Close #6178 * Support for package managers besides npm - Also fixes issue where upgrade-plugins wouldn't work
This commit is contained in:
committed by
Julian Lam
parent
96084340ad
commit
be00a1c013
@@ -6,6 +6,8 @@ var jsesc = require('jsesc');
|
||||
|
||||
var db = require('../database');
|
||||
var user = require('../user');
|
||||
var topics = require('../topics');
|
||||
var messaging = require('../messaging');
|
||||
var meta = require('../meta');
|
||||
var plugins = require('../plugins');
|
||||
var navigation = require('../navigation');
|
||||
@@ -109,10 +111,16 @@ module.exports = function (middleware) {
|
||||
next(null, translated);
|
||||
});
|
||||
},
|
||||
navigation: async.apply(navigation.get),
|
||||
navigation: navigation.get,
|
||||
tags: async.apply(meta.tags.parse, req, data, res.locals.metaTags, res.locals.linkTags),
|
||||
banned: async.apply(user.isBanned, req.uid),
|
||||
banReason: async.apply(user.getBannedReason, req.uid),
|
||||
|
||||
unreadTopicCount: async.apply(topics.getTotalUnread, req.uid),
|
||||
unreadNewTopicCount: async.apply(topics.getTotalUnread, req.uid, 'new'),
|
||||
unreadWatchedTopicCount: async.apply(topics.getTotalUnread, req.uid, 'watched'),
|
||||
unreadChatCount: async.apply(messaging.getUnreadCount, req.uid),
|
||||
unreadNotificationCount: async.apply(user.notifications.getUnreadCount, req.uid),
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
@@ -131,8 +139,45 @@ module.exports = function (middleware) {
|
||||
|
||||
setBootswatchCSS(templateValues, res.locals.config);
|
||||
|
||||
var unreadCount = {
|
||||
topic: results.unreadTopicCount || 0,
|
||||
newTopic: results.unreadNewTopicCount || 0,
|
||||
watchedTopic: results.unreadWatchedTopicCount || 0,
|
||||
chat: results.unreadChatCount || 0,
|
||||
notification: results.unreadNotificationCount || 0,
|
||||
};
|
||||
Object.keys(unreadCount).forEach(function (key) {
|
||||
if (unreadCount[key] > 99) {
|
||||
unreadCount[key] = '99+';
|
||||
}
|
||||
});
|
||||
|
||||
results.navigation = results.navigation.map(function (item) {
|
||||
if (item.originalRoute === '/unread' && results.unreadTopicCount > 0) {
|
||||
return Object.assign({}, item, {
|
||||
content: unreadCount.topic,
|
||||
iconClass: item.iconClass + ' unread-count',
|
||||
});
|
||||
}
|
||||
if (item.originalRoute === '/unread/new' && results.unreadNewTopicCount > 0) {
|
||||
return Object.assign({}, item, {
|
||||
content: unreadCount.newTopic,
|
||||
iconClass: item.iconClass + ' unread-count',
|
||||
});
|
||||
}
|
||||
if (item.originalRoute === '/unread/watched' && results.unreadWatchedTopicCount > 0) {
|
||||
return Object.assign({}, item, {
|
||||
content: unreadCount.watchedTopic,
|
||||
iconClass: item.iconClass + ' unread-count',
|
||||
});
|
||||
}
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
templateValues.browserTitle = results.browserTitle;
|
||||
templateValues.navigation = results.navigation;
|
||||
templateValues.unreadCount = unreadCount;
|
||||
templateValues.metaTags = results.tags.meta;
|
||||
templateValues.linkTags = results.tags.link;
|
||||
templateValues.isAdmin = results.user.isAdmin;
|
||||
|
||||
Reference in New Issue
Block a user