Make methods private + some props readonly

This commit is contained in:
RMidhunSuresh 2022-02-03 19:37:14 +05:30
parent 8a3c0afba6
commit 89a97537b0
2 changed files with 8 additions and 8 deletions

View File

@ -28,9 +28,9 @@ import type {
type FlowSelector = (flows: RegistrationFlow[]) => RegistrationFlow | void;
export class Registration {
private _hsApi: HomeServerApi;
private _accountDetails: AccountDetails;
private _flowSelector: FlowSelector;
private readonly _hsApi: HomeServerApi;
private readonly _accountDetails: AccountDetails;
private readonly _flowSelector: FlowSelector;
private _sessionInfo?: RegistrationResponseSuccess
constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, flowSelector?: FlowSelector) {
@ -64,7 +64,7 @@ export class Registration {
return this.parseRegistrationResponse(registrationResponse, stage);
}
parseStagesFromResponse(response: RegistrationResponseMoreDataNeeded): BaseRegistrationStage {
private parseStagesFromResponse(response: RegistrationResponseMoreDataNeeded): BaseRegistrationStage {
const { session, params } = response;
const flow = this._flowSelector(response.flows);
if (!flow) {
@ -89,7 +89,7 @@ export class Registration {
return firstStage!;
}
async parseRegistrationResponse(response: RegistrationResponse, currentStage: BaseRegistrationStage) {
private async parseRegistrationResponse(response: RegistrationResponse, currentStage: BaseRegistrationStage) {
switch (response.status) {
case 200:
this._sessionInfo = response;

View File

@ -18,11 +18,11 @@ import type {HomeServerApi} from "../../net/HomeServerApi";
import type {AccountDetails, AuthenticationData, RegistrationParams} from "../types";
export abstract class BaseRegistrationStage {
protected _hsApi: HomeServerApi;
protected _accountDetails: AccountDetails;
protected readonly _hsApi: HomeServerApi;
protected readonly _accountDetails: AccountDetails;
protected _session: string;
protected _nextStage: BaseRegistrationStage;
protected _params?: Record<string, any>
protected readonly _params?: Record<string, any>
constructor(hsApi: HomeServerApi, accountDetails: AccountDetails, session: string, params?: RegistrationParams) {
this._hsApi = hsApi;