Merge branch 'develop' into joriks/room-list-breadcrumbs
This commit is contained in:
commit
43db4b98df
38 changed files with 2362 additions and 436 deletions
|
@ -18,9 +18,9 @@ import { TagID } from "./models";
|
|||
|
||||
const TILE_HEIGHT_PX = 44;
|
||||
|
||||
// the .65 comes from the CSS where the show more button is
|
||||
// mathematically 65% of a tile when floating.
|
||||
const RESIZER_BOX_FACTOR = 0.65;
|
||||
// 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;
|
||||
|
||||
interface ISerializedListLayout {
|
||||
numTiles: number;
|
||||
|
@ -85,10 +85,16 @@ export class ListLayout {
|
|||
}
|
||||
|
||||
public get defaultVisibleTiles(): number {
|
||||
// TODO: Remove dogfood flag: https://github.com/vector-im/riot-web/issues/14231
|
||||
// TODO: Resolve dogfooding: https://github.com/vector-im/riot-web/issues/14137
|
||||
const val = Number(localStorage.getItem("mx_dogfood_rl_defTiles") || 4);
|
||||
return val + RESIZER_BOX_FACTOR;
|
||||
// 10 is what "feels right", and mostly subject to design's opinion.
|
||||
return 10 + RESIZER_BOX_FACTOR;
|
||||
}
|
||||
|
||||
public setVisibleTilesWithin(diff: number, maxPossible: number) {
|
||||
if (this.visibleTiles > maxPossible) {
|
||||
this.visibleTiles = maxPossible + diff;
|
||||
} else {
|
||||
this.visibleTiles += diff;
|
||||
}
|
||||
}
|
||||
|
||||
public calculateTilesToPixelsMin(maxTiles: number, n: number, possiblePadding: number): number {
|
||||
|
@ -122,6 +128,10 @@ export class ListLayout {
|
|||
return px / this.tileHeight;
|
||||
}
|
||||
|
||||
public reset() {
|
||||
localStorage.removeItem(this.key);
|
||||
}
|
||||
|
||||
private save() {
|
||||
localStorage.setItem(this.key, JSON.stringify(this.serialize()));
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import { TagWatcher } from "./TagWatcher";
|
|||
import RoomViewStore from "../RoomViewStore";
|
||||
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
|
||||
import { EffectiveMembership, getEffectiveMembership } from "./membership";
|
||||
import { ListLayout } from "./ListLayout";
|
||||
|
||||
interface IState {
|
||||
tagsEnabled?: boolean;
|
||||
|
@ -50,8 +51,6 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
|
|||
private tagWatcher = new TagWatcher(this);
|
||||
|
||||
private readonly watchedSettings = [
|
||||
'RoomList.orderAlphabetically',
|
||||
'RoomList.orderByImportance',
|
||||
'feature_custom_tags',
|
||||
];
|
||||
|
||||
|
@ -339,11 +338,8 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
|
|||
}
|
||||
|
||||
private async updateAlgorithmInstances() {
|
||||
const orderByImportance = SettingsStore.getValue("RoomList.orderByImportance");
|
||||
const orderAlphabetically = SettingsStore.getValue("RoomList.orderAlphabetically");
|
||||
|
||||
const defaultSort = orderAlphabetically ? SortAlgorithm.Alphabetic : SortAlgorithm.Recent;
|
||||
const defaultOrder = orderByImportance ? ListAlgorithm.Importance : ListAlgorithm.Natural;
|
||||
const defaultSort = SortAlgorithm.Alphabetic;
|
||||
const defaultOrder = ListAlgorithm.Natural;
|
||||
|
||||
for (const tag of Object.keys(this.orderedLists)) {
|
||||
const definedSort = this.getTagSorting(tag);
|
||||
|
@ -402,6 +398,15 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
|
|||
this.emit(LISTS_UPDATE_EVENT, this);
|
||||
}
|
||||
|
||||
// Note: this primarily exists for debugging, and isn't really intended to be used by anything.
|
||||
public async resetLayouts() {
|
||||
console.warn("Resetting layouts for room list");
|
||||
for (const tagId of Object.keys(this.orderedLists)) {
|
||||
new ListLayout(tagId).reset();
|
||||
}
|
||||
await this.regenerateAllLists();
|
||||
}
|
||||
|
||||
public addFilter(filter: IFilterCondition): void {
|
||||
// TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035
|
||||
console.log("Adding filter condition:", filter);
|
||||
|
|
|
@ -60,11 +60,15 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio
|
|||
|
||||
if (!room.name) return false; // should realistically not happen: the js-sdk always calculates a name
|
||||
|
||||
return this.matches(room.name);
|
||||
}
|
||||
|
||||
public matches(val: string): boolean {
|
||||
// Note: we have to match the filter with the removeHiddenChars() room name because the
|
||||
// function strips spaces and other characters (M becomes RN for example, in lowercase).
|
||||
// We also doubly convert to lowercase to work around oddities of the library.
|
||||
const noSecretsFilter = removeHiddenChars(lcFilter).toLowerCase();
|
||||
const noSecretsName = removeHiddenChars(room.name.toLowerCase()).toLowerCase();
|
||||
const noSecretsFilter = removeHiddenChars(this.search.toLowerCase()).toLowerCase();
|
||||
const noSecretsName = removeHiddenChars(val.toLowerCase()).toLowerCase();
|
||||
return noSecretsName.includes(noSecretsFilter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,11 @@ import { _t } from "../../../languageHandler";
|
|||
|
||||
export class ReactionEventPreview implements IPreview {
|
||||
public getTextFor(event: MatrixEvent, tagId?: TagID): string {
|
||||
const reaction = event.getRelation().key;
|
||||
if (!reaction) return;
|
||||
const relation = event.getRelation();
|
||||
if (!relation) return null; // invalid reaction (probably redacted)
|
||||
|
||||
const reaction = relation.key;
|
||||
if (!reaction) return null; // invalid reaction (unknown format)
|
||||
|
||||
if (isSelf(event) || !shouldPrefixMessagesIn(event.getRoomId(), tagId)) {
|
||||
return reaction;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue