Initial breakout for room list rewrite
This does a number of things (sorry): * Estimates the type changes needed to the dispatcher (later to be replaced by https://github.com/matrix-org/matrix-react-sdk/pull/4593) * Sets up the stack for a whole new room list store, and later components for usage. * Create a proxy class to ensure the app still functions as expected when the various stores are enabled/disabled * Demonstrates a possible structure for algorithms
This commit is contained in:
parent
82b55ffd77
commit
08419d195e
21 changed files with 794 additions and 47 deletions
|
@ -112,11 +112,19 @@ class RoomListStore extends Store {
|
|||
constructor() {
|
||||
super(dis);
|
||||
|
||||
this._checkDisabled();
|
||||
this._init();
|
||||
this._getManualComparator = this._getManualComparator.bind(this);
|
||||
this._recentsComparator = this._recentsComparator.bind(this);
|
||||
}
|
||||
|
||||
_checkDisabled() {
|
||||
this.disabled = SettingsStore.isFeatureEnabled("feature_new_room_list");
|
||||
if (this.disabled) {
|
||||
console.warn("DISABLING LEGACY ROOM LIST STORE");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the sorting algorithm used by the RoomListStore.
|
||||
* @param {string} algorithm The new algorithm to use. Should be one of the ALGO_* constants.
|
||||
|
@ -133,6 +141,8 @@ class RoomListStore extends Store {
|
|||
}
|
||||
|
||||
_init() {
|
||||
if (this.disabled) return;
|
||||
|
||||
// Initialise state
|
||||
const defaultLists = {
|
||||
"m.server_notice": [/* { room: js-sdk room, category: string } */],
|
||||
|
@ -160,6 +170,8 @@ class RoomListStore extends Store {
|
|||
}
|
||||
|
||||
_setState(newState) {
|
||||
if (this.disabled) return;
|
||||
|
||||
// If we're changing the lists, transparently change the presentation lists (which
|
||||
// is given to requesting components). This dramatically simplifies our code elsewhere
|
||||
// while also ensuring we don't need to update all the calling components to support
|
||||
|
@ -176,6 +188,8 @@ class RoomListStore extends Store {
|
|||
}
|
||||
|
||||
__onDispatch(payload) {
|
||||
if (this.disabled) return;
|
||||
|
||||
const logicallyReady = this._matrixClient && this._state.ready;
|
||||
switch (payload.action) {
|
||||
case 'setting_updated': {
|
||||
|
@ -202,6 +216,9 @@ class RoomListStore extends Store {
|
|||
break;
|
||||
}
|
||||
|
||||
this._checkDisabled();
|
||||
if (this.disabled) return;
|
||||
|
||||
// Always ensure that we set any state needed for settings here. It is possible that
|
||||
// setting updates trigger on startup before we are ready to sync, so we want to make
|
||||
// sure that the right state is in place before we actually react to those changes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue