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

@@ -8,6 +8,7 @@ var websockets = require('./index');
var user = require('../user');
var posts = require('../posts');
var topics = require('../topics');
var categories = require('../categories');
var privileges = require('../privileges');
var notifications = require('../notifications');
var plugins = require('../plugins');
@@ -63,15 +64,15 @@ function filterTidCidIgnorers(uids, tid, cid, callback) {
topicIgnored: function (next) {
db.isSetMembers('tid:' + tid + ':ignorers', uids, next);
},
categoryIgnored: function (next) {
db.sortedSetScores('cid:' + cid + ':ignorers', uids, next);
categoryWatchStates: function (next) {
categories.getUidsWatchStates(cid, uids, next);
},
}, next);
},
function (results, next) {
uids = uids.filter(function (uid, index) {
return results.topicFollowed[index] ||
(!results.topicFollowed[index] && !results.topicIgnored[index] && !results.categoryIgnored[index]);
(!results.topicIgnored[index] && results.categoryWatchStates[index] !== categories.watchStates.ignoring);
});
next(null, uids);
},