mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
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:
committed by
GitHub
parent
2104877c76
commit
eb7ae54f81
@@ -284,18 +284,22 @@ describe('Categories', function () {
|
||||
});
|
||||
|
||||
it('should ignore category', function (done) {
|
||||
socketCategories.ignore({ uid: posterUid }, categoryObj.cid, function (err) {
|
||||
socketCategories.ignore({ uid: posterUid }, { cid: categoryObj.cid }, function (err) {
|
||||
assert.ifError(err);
|
||||
Categories.isIgnored([categoryObj.cid], posterUid, function (err, isIgnored) {
|
||||
assert.ifError(err);
|
||||
assert.equal(isIgnored[0], true);
|
||||
done();
|
||||
Categories.getIgnorers(categoryObj.cid, 0, -1, function (err, ignorers) {
|
||||
assert.ifError(err);
|
||||
assert.deepEqual(ignorers, [posterUid]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should watch category', function (done) {
|
||||
socketCategories.watch({ uid: posterUid }, categoryObj.cid, function (err) {
|
||||
socketCategories.watch({ uid: posterUid }, { cid: categoryObj.cid }, function (err) {
|
||||
assert.ifError(err);
|
||||
Categories.isIgnored([categoryObj.cid], posterUid, function (err, isIgnored) {
|
||||
assert.ifError(err);
|
||||
@@ -305,6 +309,13 @@ describe('Categories', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if watch state does not exist', function (done) {
|
||||
socketCategories.setWatchState({ uid: posterUid }, { cid: categoryObj.cid, state: 'invalid-state' }, function (err) {
|
||||
assert.equal(err.message, '[[error:invalid-watch-state]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should check if user is moderator', function (done) {
|
||||
socketCategories.isModerator({ uid: posterUid }, {}, function (err, isModerator) {
|
||||
assert.ifError(err);
|
||||
|
||||
Reference in New Issue
Block a user