Fix error on account creation
Change-Id: Ie8fe7f0bb8e6a2f55a09196530eebac0a10746d3
diff --git a/model/Account.ts b/model/Account.ts
index ce529c0..0355de4 100644
--- a/model/Account.ts
+++ b/model/Account.ts
@@ -25,14 +25,14 @@
private readonly id: string;
private _details: AccountDetails;
private _volatileDetails: VolatileDetails;
- private contactCache: Record<string, Contact> = {};
- private _contacts: Contact[] = [];
- private conversations: Record<string, Conversation> = {};
- private defaultModerators: Contact[] = [];
- private _lookups: Lookup[] = [];
- private devices: Devices = {};
- private _registrationState: RegistrationState | undefined = undefined;
- private _registeringName: AccountRegisteringName | undefined = undefined;
+ private readonly contactCache: Record<string, Contact>;
+ private _contacts: Contact[];
+ private readonly conversations: Record<string, Conversation>;
+ private defaultModerators: Contact[];
+ private _lookups: Lookup[];
+ private devices: Devices;
+ private _registrationState: RegistrationState | undefined;
+ private _registeringName: AccountRegisteringName | undefined;
static TYPE_JAMI: string;
static TYPE_SIP: string;
@@ -41,13 +41,21 @@
constructor(id: string, details: AccountDetails, volatileDetails: VolatileDetails) {
this.id = id;
- this._details = details;
- this._volatileDetails = volatileDetails;
+ this._details = details || {};
+ this._volatileDetails = volatileDetails || {};
+ this.contactCache = {};
+ this._contacts = [];
+ this.conversations = {};
+ this.defaultModerators = [];
+ this._lookups = [];
+ this.devices = {};
+ this.registrationState = undefined;
+ this._registeringName = undefined;
}
- static from(object: Account) {
- const account = new Account(object.id, object._details, object._volatileDetails);
- if (object.defaultModerators) account.defaultModerators = object.defaultModerators.map((m) => Contact.from(m));
+ static from(object: any) {
+ const account = new Account(object.id, object.details, object.volatileDetails);
+ if (object.defaultModerators) account.defaultModerators = object.defaultModerators.map((m: any) => Contact.from(m));
return account;
}