mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +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);
|
||||
}
|
||||
|
||||
with(segment: Segment<T>): Path<T> | null {
|
||||
with(segment: Segment<T>): Path<T> | undefined {
|
||||
let index = this._segments.length - 1;
|
||||
do {
|
||||
if (this._allowsChild(this._segments[index], segment)) {
|
||||
@ -149,7 +149,7 @@ class Path<T> {
|
||||
index -= 1;
|
||||
} while(index >= -1);
|
||||
// allow -1 as well so we check if the segment is allowed as root
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
until(type: keyof T): Path<T> {
|
||||
@ -164,7 +164,7 @@ class Path<T> {
|
||||
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);
|
||||
if (index !== -1) {
|
||||
const parent = this._segments[index - 1];
|
||||
@ -177,7 +177,7 @@ class Path<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get segments(): Segment<T>[] {
|
||||
|
@ -106,7 +106,7 @@ export class URLRouter<T extends {session: string}> {
|
||||
}
|
||||
|
||||
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) {
|
||||
path = path.with(segment);
|
||||
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 {
|
||||
let newPath: Path<SegmentType> | null = path;
|
||||
export function removeRoomFromPath(path: Path<SegmentType>, roomId: string): Path<SegmentType> | undefined {
|
||||
let newPath: Path<SegmentType> | undefined = path;
|
||||
const rooms = newPath.get("rooms");
|
||||
let roomIdGridIndex = -1;
|
||||
// first delete from rooms segment
|
||||
|
Loading…
Reference in New Issue
Block a user