Support list collapsing and jumping

Fixes https://github.com/vector-im/riot-web/issues/14036
This commit is contained in:
Travis Ralston 2020-06-15 19:47:25 -06:00
parent 8596905cee
commit 4186070489
5 changed files with 81 additions and 2 deletions

View file

@ -21,11 +21,13 @@ const TILE_HEIGHT_PX = 44;
interface ISerializedListLayout {
numTiles: number;
showPreviews: boolean;
collapsed: boolean;
}
export class ListLayout {
private _n = 0;
private _previews = false;
private _collapsed = false;
constructor(public readonly tagId: TagID) {
const serialized = localStorage.getItem(this.key);
@ -34,9 +36,19 @@ export class ListLayout {
const parsed = <ISerializedListLayout>JSON.parse(serialized);
this._n = parsed.numTiles;
this._previews = parsed.showPreviews;
this._collapsed = parsed.collapsed;
}
}
public get isCollapsed(): boolean {
return this._collapsed;
}
public set isCollapsed(v: boolean) {
this._collapsed = v;
this.save();
}
public get showPreviews(): boolean {
return this._previews;
}
@ -100,6 +112,7 @@ export class ListLayout {
return {
numTiles: this.visibleTiles,
showPreviews: this.showPreviews,
collapsed: this.isCollapsed,
};
}
}