mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Make more functions private
This commit is contained in:
parent
2dd050bd90
commit
69e67ad5ac
@ -42,11 +42,11 @@ export class HomeServerApi {
|
|||||||
this._reconnector = reconnector;
|
this._reconnector = reconnector;
|
||||||
}
|
}
|
||||||
|
|
||||||
_url(csPath: string, prefix: string = CS_R0_PREFIX): string {
|
private _url(csPath: string, prefix: string = CS_R0_PREFIX): string {
|
||||||
return this._homeserver + prefix + csPath;
|
return this._homeserver + prefix + csPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
_baseRequest(method: RequestMethod, url: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions, accessToken?: string): HomeServerRequest {
|
private _baseRequest(method: RequestMethod, url: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions, accessToken?: string): HomeServerRequest {
|
||||||
const queryString = encodeQueryParams(queryParams);
|
const queryString = encodeQueryParams(queryParams);
|
||||||
url = `${url}?${queryString}`;
|
url = `${url}?${queryString}`;
|
||||||
let log: LogItem | undefined;
|
let log: LogItem | undefined;
|
||||||
@ -98,23 +98,23 @@ export class HomeServerApi {
|
|||||||
return hsRequest;
|
return hsRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unauthedRequest(method: RequestMethod, url: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
private _unauthedRequest(method: RequestMethod, url: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
||||||
return this._baseRequest(method, url, queryParams, body, options);
|
return this._baseRequest(method, url, queryParams, body, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
_authedRequest(method: RequestMethod, url: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
private _authedRequest(method: RequestMethod, url: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
||||||
return this._baseRequest(method, url, queryParams, body, options, this._accessToken);
|
return this._baseRequest(method, url, queryParams, body, options, this._accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
_post(csPath: string, queryParams: Record<string, any>, body: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
private _post(csPath: string, queryParams: Record<string, any>, body: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
||||||
return this._authedRequest("POST", this._url(csPath, options?.prefix || CS_R0_PREFIX), queryParams, body, options);
|
return this._authedRequest("POST", this._url(csPath, options?.prefix || CS_R0_PREFIX), queryParams, body, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
_put(csPath: string, queryParams: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
private _put(csPath: string, queryParams: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
||||||
return this._authedRequest("PUT", this._url(csPath, options?.prefix || CS_R0_PREFIX), queryParams, body, options);
|
return this._authedRequest("PUT", this._url(csPath, options?.prefix || CS_R0_PREFIX), queryParams, body, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
_get(csPath: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
private _get(csPath: string, queryParams?: Record<string, any>, body?: Record<string, any>, options?: IRequestOptions): HomeServerRequest {
|
||||||
return this._authedRequest("GET", this._url(csPath, options?.prefix || CS_R0_PREFIX), queryParams, body, options);
|
return this._authedRequest("GET", this._url(csPath, options?.prefix || CS_R0_PREFIX), queryParams, body, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,9 +275,8 @@ export function tests() {
|
|||||||
request: () => new MockRequest().respond(200, 42),
|
request: () => new MockRequest().respond(200, 42),
|
||||||
homeserver: "https://hs.tld",
|
homeserver: "https://hs.tld",
|
||||||
});
|
});
|
||||||
const result = await hsApi
|
// @ts-ignore
|
||||||
._get("foo", undefined, undefined, undefined)
|
const result = await hsApi._get("foo", undefined, undefined, undefined).response();
|
||||||
.response();
|
|
||||||
assert.strictEqual(result, 42);
|
assert.strictEqual(result, 42);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ export class MediaRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_parseMxcUrl(url: string): string[] | null {
|
private _parseMxcUrl(url: string): string[] | null {
|
||||||
const prefix = "mxc://";
|
const prefix = "mxc://";
|
||||||
if (url.startsWith(prefix)) {
|
if (url.startsWith(prefix)) {
|
||||||
return url.substr(prefix.length).split("/", 2);
|
return url.substr(prefix.length).split("/", 2);
|
||||||
|
@ -93,7 +93,7 @@ export class Reconnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_setState(state: ConnectionStatus): void {
|
private _setState(state: ConnectionStatus): void {
|
||||||
if (state !== this._state.get()) {
|
if (state !== this._state.get()) {
|
||||||
if (state === ConnectionStatus.Waiting) {
|
if (state === ConnectionStatus.Waiting) {
|
||||||
this._stateSince = this._createTimeMeasure();
|
this._stateSince = this._createTimeMeasure();
|
||||||
@ -104,7 +104,7 @@ export class Reconnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _reconnectLoop(hsApi: HomeServerApi): Promise<void> {
|
private async _reconnectLoop(hsApi: HomeServerApi): Promise<void> {
|
||||||
this._versionsResponse = undefined;
|
this._versionsResponse = undefined;
|
||||||
this._retryDelay.reset();
|
this._retryDelay.reset();
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ export class RequestScheduler {
|
|||||||
this._stopped = false;
|
this._stopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hsApiRequest(name: string, args: any[]): Request {
|
private _hsApiRequest(name: string, args: any[]): Request {
|
||||||
const request = new Request(name, args);
|
const request = new Request(name, args);
|
||||||
this._doSend(request);
|
this._doSend(request);
|
||||||
return request;
|
return request;
|
||||||
|
Loading…
Reference in New Issue
Block a user