mirror of https://github.com/zulip/zulip.git
message_list_data: Remove dependency on `filter.js`.
This commit removes dependency on `filter.js` by lifting the construction of `Filter` object up in `all_messages_data.js`.
This commit is contained in:
parent
fc22b86eb6
commit
9e1b4dafc0
|
@ -1,5 +1,7 @@
|
|||
import {Filter} from "./filter";
|
||||
import {MessageListData} from "./message_list_data";
|
||||
|
||||
export const all_messages_data = new MessageListData({
|
||||
excludes_muted_topics: false,
|
||||
filter: new Filter(),
|
||||
});
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as blueslip from "./blueslip";
|
||||
import {FetchStatus} from "./fetch_status";
|
||||
import {Filter} from "./filter";
|
||||
import * as muted_users from "./muted_users";
|
||||
import {page_params} from "./page_params";
|
||||
import * as unread from "./unread";
|
||||
|
@ -15,7 +14,7 @@ export class MessageListData {
|
|||
// See also MessageList and MessageListView, which are important
|
||||
// to actually display a message list.
|
||||
|
||||
constructor({excludes_muted_topics, filter = new Filter()}) {
|
||||
constructor({excludes_muted_topics, filter}) {
|
||||
// The Filter object defines which messages match the narrow,
|
||||
// and defines most of the configuration for the MessageListData.
|
||||
this.filter = filter;
|
||||
|
|
|
@ -135,7 +135,9 @@ run_test("basics", ({override}) => {
|
|||
});
|
||||
|
||||
run_test("prev_next", () => {
|
||||
const list = new MessageList({});
|
||||
const list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
|
||||
assert.equal(list.prev(), undefined);
|
||||
assert.equal(list.next(), undefined);
|
||||
|
@ -174,7 +176,9 @@ run_test("prev_next", () => {
|
|||
});
|
||||
|
||||
run_test("message_range", () => {
|
||||
const list = new MessageList({});
|
||||
const list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
|
||||
const messages = [{id: 30}, {id: 40}, {id: 50}, {id: 60}];
|
||||
list.append(messages, true);
|
||||
|
@ -188,7 +192,9 @@ run_test("message_range", () => {
|
|||
});
|
||||
|
||||
run_test("nth_most_recent_id", () => {
|
||||
const list = new MessageList({});
|
||||
const list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
list.append([{id: 10}, {id: 20}, {id: 30}]);
|
||||
assert.equal(list.nth_most_recent_id(1), 30);
|
||||
assert.equal(list.nth_most_recent_id(2), 20);
|
||||
|
@ -197,7 +203,9 @@ run_test("nth_most_recent_id", () => {
|
|||
});
|
||||
|
||||
run_test("change_message_id", () => {
|
||||
const list = new MessageList({});
|
||||
const list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
list.data._add_to_hash([
|
||||
{id: 10.5, content: "good job"},
|
||||
{id: 20.5, content: "ok!"},
|
||||
|
@ -218,7 +226,9 @@ run_test("change_message_id", () => {
|
|||
});
|
||||
|
||||
run_test("last_sent_by_me", () => {
|
||||
const list = new MessageList({});
|
||||
const list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
const items = [
|
||||
{
|
||||
id: 1,
|
||||
|
@ -241,7 +251,9 @@ run_test("last_sent_by_me", () => {
|
|||
});
|
||||
|
||||
run_test("local_echo", () => {
|
||||
let list = new MessageList({});
|
||||
let list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
list.append([
|
||||
{id: 10},
|
||||
{id: 20},
|
||||
|
@ -271,7 +283,9 @@ run_test("local_echo", () => {
|
|||
assert.equal(list.closest_id(54), 50);
|
||||
assert.equal(list.closest_id(58), 60);
|
||||
|
||||
list = new MessageList({});
|
||||
list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
list.append([
|
||||
{id: 10},
|
||||
{id: 20},
|
||||
|
@ -311,7 +325,9 @@ run_test("local_echo", () => {
|
|||
});
|
||||
|
||||
run_test("bookend", ({override}) => {
|
||||
const list = new MessageList({});
|
||||
const list = new MessageList({
|
||||
filter: new Filter(),
|
||||
});
|
||||
|
||||
list.view.clear_trailing_bookend = noop;
|
||||
list.narrowed = true;
|
||||
|
|
|
@ -39,6 +39,7 @@ function assert_msg_ids(messages, msg_ids) {
|
|||
run_test("basics", () => {
|
||||
const mld = new MessageListData({
|
||||
excludes_muted_topics: false,
|
||||
filter: new Filter(),
|
||||
});
|
||||
|
||||
assert.equal(mld.is_search(), false);
|
||||
|
@ -205,6 +206,7 @@ run_test("muting", () => {
|
|||
// and keep `_all_items` up-to-date.
|
||||
mld = new MessageListData({
|
||||
excludes_muted_topics: true,
|
||||
filter: new Filter(),
|
||||
});
|
||||
assert.deepEqual(mld._all_items, []);
|
||||
|
||||
|
@ -239,6 +241,7 @@ run_test("muting", () => {
|
|||
// filtering the messages.
|
||||
mld = new MessageListData({
|
||||
excludes_muted_topics: true,
|
||||
filter: new Filter(),
|
||||
});
|
||||
|
||||
const orig_messages = [
|
||||
|
@ -286,6 +289,7 @@ run_test("muting", () => {
|
|||
run_test("errors", () => {
|
||||
const mld = new MessageListData({
|
||||
excludes_muted_topics: false,
|
||||
filter: new Filter(),
|
||||
});
|
||||
assert.equal(mld.get("bogus-id"), undefined);
|
||||
|
||||
|
|
Loading…
Reference in New Issue