message_list_data: Move comments to the type definitions.

This commit is contained in:
Aman Agrawal 2024-04-17 09:26:31 +00:00 committed by Tim Abbott
parent 1d5897060a
commit 6d7856fa37
1 changed files with 23 additions and 29 deletions

View File

@ -9,13 +9,36 @@ import * as user_topics from "./user_topics";
import * as util from "./util";
export class MessageListData {
// The Filter object defines which messages match the narrow,
// and defines most of the configuration for the MessageListData.
filter: Filter;
// The FetchStatus object keeps track of our understanding of
// to what extent this MessageListData has all the messages
// that the server possesses matching this narrow, and whether
// we're in the progress of fetching more.
fetch_status: FetchStatus;
// _all_items is a sorted list of all message objects that
// match this.filter, regardless of muting.
//
// Most code will instead use _items, which contains
// only messages that should be displayed after excluding
// muted topics and messages sent by muted users.
_all_items: Message[];
_items: Message[];
// _hash contains the same messages as _all_items, mapped by
// message ID. It's used to efficiently query if a given
// message is present.
_hash: Map<number, Message>;
// Some views exclude muted topics.
//
// TODO: Refactor this to be a property of Filter, rather than
// a parameter that needs to be passed into the constructor.
excludes_muted_topics: boolean;
// Tracks any locally echoed messages, which we know aren't present on the server.
_local_only: Set<number>;
// The currently selected message ID. The special value -1
// there is no selected message. A common situation is when
// there are no messages matching the current filter.
_selected_id: number;
predicate?: (message: Message) => boolean;
@ -27,42 +50,13 @@ export class MessageListData {
// to actually display a message list.
constructor({excludes_muted_topics, filter}: {excludes_muted_topics: boolean; filter: Filter}) {
// The Filter object defines which messages match the narrow,
// and defines most of the configuration for the MessageListData.
this.filter = filter;
// The FetchStatus object keeps track of our understanding of
// to what extent this MessageListData has all the messages
// that the server possesses matching this narrow, and whether
// we're in the progress of fetching more.
this.fetch_status = new FetchStatus();
// _all_items is a sorted list of all message objects that
// match this.filter, regardless of muting.
//
// Most code will instead use _items, which contains
// only messages that should be displayed after excluding
// muted topics and messages sent by muted users.
this._all_items = [];
this._items = [];
// _hash contains the same messages as _all_items, mapped by
// message ID. It's used to efficiently query if a given
// message is present.
this._hash = new Map();
// Some views exclude muted topics.
//
// TODO: Refactor this to be a property of Filter, rather than
// a parameter that needs to be passed into the constructor..
this.excludes_muted_topics = excludes_muted_topics;
// Tracks any locally echoed messages, which we know aren't present on the server.
this._local_only = new Set();
// The currently selected message ID. The special value -1
// there is no selected message. A common situation is when
// there are no messages matching the current filter.
this._selected_id = -1;
}