mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Use undefined instead of null
This commit is contained in:
parent
5be00f051f
commit
4ae3a5bf7a
@ -137,7 +137,7 @@ class Path<T> {
|
|||||||
return new Path(this._segments.slice(), this._allowsChild);
|
return new Path(this._segments.slice(), this._allowsChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
with(segment: Segment<T>): Path<T> | null {
|
with(segment: Segment<T>): Path<T> | undefined {
|
||||||
let index = this._segments.length - 1;
|
let index = this._segments.length - 1;
|
||||||
do {
|
do {
|
||||||
if (this._allowsChild(this._segments[index], segment)) {
|
if (this._allowsChild(this._segments[index], segment)) {
|
||||||
@ -149,7 +149,7 @@ class Path<T> {
|
|||||||
index -= 1;
|
index -= 1;
|
||||||
} while(index >= -1);
|
} while(index >= -1);
|
||||||
// allow -1 as well so we check if the segment is allowed as root
|
// allow -1 as well so we check if the segment is allowed as root
|
||||||
return null;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
until(type: keyof T): Path<T> {
|
until(type: keyof T): Path<T> {
|
||||||
@ -164,7 +164,7 @@ class Path<T> {
|
|||||||
return this._segments.find(s => s.type === type);
|
return this._segments.find(s => s.type === type);
|
||||||
}
|
}
|
||||||
|
|
||||||
replace(segment: Segment<T>): Path<T> | null {
|
replace(segment: Segment<T>): Path<T> | undefined {
|
||||||
const index = this._segments.findIndex(s => s.type === segment.type);
|
const index = this._segments.findIndex(s => s.type === segment.type);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
const parent = this._segments[index - 1];
|
const parent = this._segments[index - 1];
|
||||||
@ -177,7 +177,7 @@ class Path<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
get segments(): Segment<T>[] {
|
get segments(): Segment<T>[] {
|
||||||
|
@ -106,7 +106,7 @@ export class URLRouter<T extends {session: string}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
urlForSegments(segments: Segment<T>[]): string | undefined {
|
urlForSegments(segments: Segment<T>[]): string | undefined {
|
||||||
let path: Path<T> | null = this._navigation.path;
|
let path: Path<T> | undefined = this._navigation.path;
|
||||||
for (const segment of segments) {
|
for (const segment of segments) {
|
||||||
path = path.with(segment);
|
path = path.with(segment);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
|
@ -63,8 +63,8 @@ function allowsChild(parent: Segment<SegmentType> | undefined, child: Segment<Se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeRoomFromPath(path: Path<SegmentType>, roomId: string): Path<SegmentType> | null {
|
export function removeRoomFromPath(path: Path<SegmentType>, roomId: string): Path<SegmentType> | undefined {
|
||||||
let newPath: Path<SegmentType> | null = path;
|
let newPath: Path<SegmentType> | undefined = path;
|
||||||
const rooms = newPath.get("rooms");
|
const rooms = newPath.get("rooms");
|
||||||
let roomIdGridIndex = -1;
|
let roomIdGridIndex = -1;
|
||||||
// first delete from rooms segment
|
// first delete from rooms segment
|
||||||
|
Loading…
Reference in New Issue
Block a user