Category watch state (#7109)

* feat: wip, category watch change

* feat: pass data to client

* feat: allow changing state

* fix: account page categories

* fix: show in unread if topic is followed or category is watched

* feat: add default watch state to acp

* feat: save user category watch state

* feat: update unread recent pages

* fix: remove dupe code

* fix: flip conditions

* fix: handle empty arrays

* fix: ignore/watch on others profile

* feat: upgrade script for category states

if there are any users ignoring categories set their state in new zset and delete cid:<cid>:ignorers

* fix: upgrade

* fix: tests

* fix: redis count

* fix: more tests
This commit is contained in:
Barış Soner Uşaklı
2018-12-14 16:24:17 -05:00
committed by GitHub
parent 2104877c76
commit eb7ae54f81
28 changed files with 376 additions and 136 deletions

View File

@@ -194,8 +194,8 @@ module.exports = function (Topics) {
isTopicsFollowed: function (next) {
db.sortedSetScores('uid:' + uid + ':followed_tids', tids, next);
},
ignoredCids: function (next) {
categories.isIgnored(cids, uid, next);
categoryWatchState: function (next) {
categories.getWatchState(cids, uid, next);
},
readableCids: function (next) {
privileges.categories.filterCids('read', cids, uid, next);
@@ -205,7 +205,7 @@ module.exports = function (Topics) {
function (results, next) {
cid = cid && cid.map(String);
results.readableCids = results.readableCids.map(String);
const isCidIgnored = _.zipObject(cids, results.ignoredCids);
const userCidState = _.zipObject(cids, results.categoryWatchState);
topicData.forEach(function (topic, index) {
function cidMatch(topicCid) {
@@ -214,7 +214,7 @@ module.exports = function (Topics) {
if (topic && topic.cid && cidMatch(topic.cid) && !blockedUids.includes(parseInt(topic.uid, 10))) {
topic.tid = parseInt(topic.tid, 10);
if ((results.isTopicsFollowed[index] || !isCidIgnored[topic.cid])) {
if ((results.isTopicsFollowed[index] || userCidState[topic.cid] === categories.watchStates.watching)) {
tidsByFilter[''].push(topic.tid);
}