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