mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-11 10:03:44 +01:00
fix: marking remote category topics as read
This commit is contained in:
@@ -68,7 +68,7 @@ define('forum/unread', [
|
||||
markAllRead();
|
||||
} else if (category.cid === 'selected') {
|
||||
markSelectedRead();
|
||||
} else if (parseInt(category.cid, 10) > 0) {
|
||||
} else if (category.cid) {
|
||||
markCategoryRead(category.cid);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const topics = require('../../topics');
|
||||
const categories = require('../../categories');
|
||||
|
||||
const api = require('../../api');
|
||||
const sockets = require('..');
|
||||
@@ -32,6 +33,10 @@ module.exports = function (SocketTopics) {
|
||||
};
|
||||
|
||||
SocketTopics.markCategoryTopicsRead = async function (socket, cid) {
|
||||
const exists = await categories.exists(cid);
|
||||
if (!exists) {
|
||||
throw new Error('[[error:invalid-cid]]');
|
||||
}
|
||||
const tids = await topics.getUnreadTids({ cid: cid, uid: socket.uid, filter: '' });
|
||||
await SocketTopics.markAsRead(socket, tids);
|
||||
};
|
||||
|
||||
@@ -148,7 +148,7 @@ module.exports = function (Topics) {
|
||||
const categoryWatchState = await categories.getWatchState(topicCids, params.uid);
|
||||
const userCidState = _.zipObject(topicCids, categoryWatchState);
|
||||
|
||||
const filterCids = params.cid && params.cid.map(cid => parseInt(cid, 10));
|
||||
const filterCids = params.cid && params.cid.map(cid => utils.isNumber(cid) ? parseInt(cid, 10) : cid);
|
||||
const filterTags = params.tag && params.tag.map(tag => String(tag));
|
||||
|
||||
topicData.forEach((topic) => {
|
||||
|
||||
Reference in New Issue
Block a user