mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 02:45:24 +08:00
FIX: Invisible is not the opposite of visible (#11881)
If visible is undefined, then invisible should be too.
This commit is contained in:
parent
b70e0d88f7
commit
8e53c2a2c3
@ -1,4 +1,4 @@
|
||||
import { and, equal, not, notEmpty, or } from "@ember/object/computed";
|
||||
import { and, equal, notEmpty, or } from "@ember/object/computed";
|
||||
import { fmt, propertyEqual } from "discourse/lib/computed";
|
||||
import ActionSummary from "discourse/models/action-summary";
|
||||
import Category from "discourse/models/category";
|
||||
@ -210,7 +210,11 @@ const Topic = RestModel.extend({
|
||||
});
|
||||
},
|
||||
|
||||
invisible: not("visible"),
|
||||
@discourseComputed("visible")
|
||||
invisible(visible) {
|
||||
return visible !== undefined ? !visible : undefined;
|
||||
},
|
||||
|
||||
deleted: notEmpty("deleted_at"),
|
||||
|
||||
@discourseComputed("id")
|
||||
|
@ -163,4 +163,18 @@ discourseModule("Unit | Model | topic", function () {
|
||||
"supports emojis"
|
||||
);
|
||||
});
|
||||
|
||||
test("visible & invisible", function (assert) {
|
||||
const topic = Topic.create();
|
||||
assert.equal(topic.visible, undefined);
|
||||
assert.equal(topic.invisible, undefined);
|
||||
|
||||
const visibleTopic = Topic.create({ visible: true });
|
||||
assert.equal(visibleTopic.visible, true);
|
||||
assert.equal(visibleTopic.invisible, false);
|
||||
|
||||
const invisibleTopic = Topic.create({ visible: false });
|
||||
assert.equal(invisibleTopic.visible, false);
|
||||
assert.equal(invisibleTopic.invisible, true);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user