Merge branch 'develop' into travis/room-list/enable

This commit is contained in:
Travis Ralston 2020-07-10 11:11:25 -06:00
commit bdb641279a
5 changed files with 180 additions and 126 deletions

View file

@ -20,7 +20,8 @@ const TILE_HEIGHT_PX = 44;
// this comes from the CSS where the show more button is
// mathematically this percent of a tile when floating.
const RESIZER_BOX_FACTOR = 0.78;
//const RESIZER_BOX_FACTOR = 0.78;
const RESIZER_BOX_FACTOR = 0;
interface ISerializedListLayout {
numTiles: number;
@ -109,6 +110,10 @@ export class ListLayout {
return this.tilesToPixels(Math.min(maxTiles, n)) + padding;
}
public tilesWithResizerBoxFactor(n: number): number {
return n + RESIZER_BOX_FACTOR;
}
public tilesWithPadding(n: number, paddingPx: number): number {
return this.pixelsToTiles(this.tilesToPixelsWithPadding(n, paddingPx));
}

View file

@ -25,7 +25,7 @@ import { IListOrderingMap, ITagMap, ITagSortingMap, ListAlgorithm, SortAlgorithm
import { ActionPayload } from "../../dispatcher/payloads";
import defaultDispatcher from "../../dispatcher/dispatcher";
import { readReceiptChangeIsFor } from "../../utils/read-receipts";
import { IFilterCondition } from "./filters/IFilterCondition";
import { FILTER_CHANGED, IFilterCondition } from "./filters/IFilterCondition";
import { TagWatcher } from "./TagWatcher";
import RoomViewStore from "../RoomViewStore";
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
@ -71,6 +71,7 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
for (const settingName of this.watchedSettings) SettingsStore.monitorSetting(settingName, null);
RoomViewStore.addListener(() => this.handleRVSUpdate({}));
this.algorithm.on(LIST_UPDATED_EVENT, this.onAlgorithmListUpdated);
this.algorithm.on(FILTER_CHANGED, this.onAlgorithmFilterUpdated);
}
public get orderedLists(): ITagMap {
@ -512,6 +513,11 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
this.updateFn.mark();
};
private onAlgorithmFilterUpdated = () => {
// The filter can happen off-cycle, so trigger an update if we need to.
this.updateFn.triggerIfWillMark();
};
/**
* Regenerates the room whole room list, discarding any previous results.
*

View file

@ -153,11 +153,11 @@ export class Algorithm extends EventEmitter {
// Populate the cache of the new filter
this.allowedByFilter.set(filterCondition, this.rooms.filter(r => filterCondition.isVisible(r)));
this.recalculateFilteredRooms();
filterCondition.on(FILTER_CHANGED, this.recalculateFilteredRooms.bind(this));
filterCondition.on(FILTER_CHANGED, this.handleFilterChange.bind(this));
}
public removeFilterCondition(filterCondition: IFilterCondition): void {
filterCondition.off(FILTER_CHANGED, this.recalculateFilteredRooms.bind(this));
filterCondition.off(FILTER_CHANGED, this.handleFilterChange.bind(this));
if (this.allowedByFilter.has(filterCondition)) {
this.allowedByFilter.delete(filterCondition);
@ -169,6 +169,13 @@ export class Algorithm extends EventEmitter {
}
}
private async handleFilterChange() {
await this.recalculateFilteredRooms();
// re-emit the update so the list store can fire an off-cycle update if needed
this.emit(FILTER_CHANGED);
}
private async updateStickyRoom(val: Room) {
try {
return await this.doUpdateStickyRoom(val);