From 7f19bc2f8ca3b22b49c8d2ee27fbda942a68b58c Mon Sep 17 00:00:00 2001 From: Huan LI Date: Thu, 11 Jul 2019 03:13:51 +0800 Subject: [PATCH] readonly id in constructor --- src/user/contact.ts | 6 +----- src/user/friendship.ts | 38 +------------------------------------ src/user/room-invitation.ts | 2 +- src/user/room.ts | 6 +----- 4 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/user/contact.ts b/src/user/contact.ts index 3263e58ab..b18e62b86 100644 --- a/src/user/contact.ts +++ b/src/user/contact.ts @@ -257,19 +257,15 @@ export class Contact extends Accessory implements Sayable { */ protected payload?: ContactPayload - public readonly id: string // Contact Id - /** * @private */ constructor ( - id: string, + public readonly id: string, ) { super() log.silly('Contact', `constructor(${id})`) - this.id = id - // tslint:disable-next-line:variable-name const MyClass = instanceToClass(this, Contact) diff --git a/src/user/friendship.ts b/src/user/friendship.ts index b54cafb4a..ee8aef42d 100644 --- a/src/user/friendship.ts +++ b/src/user/friendship.ts @@ -114,42 +114,6 @@ export class Friendship extends Accessory implements Acceptable { throw new Error('to be implemented') } - // public static createConfirm( - // contactId: string, - // ): FriendRequestPayload { - // log.verbose('Friendship', 'createConfirm(%s)', - // contactId, - // ) - - // const payload: FriendRequestPayloadConfirm = { - // type : FriendRequestType.Confirm, - // contactId, - // } - - // return payload - // } - - // public static createReceive( - // contactId : string, - // hello : string, - // ticket : string, - // ): FriendRequestPayload { - // log.verbose('Friendship', 'createReceive(%s, %s, %s)', - // contactId, - // hello, - // ticket, - // ) - - // const payload: FriendRequestPayloadReceive = { - // type : FriendRequestType.Receive, - // contactId, - // hello, - // ticket, - // } - - // return payload - // } - /** * * Instance Properties @@ -162,7 +126,7 @@ export class Friendship extends Accessory implements Acceptable { protected payload?: FriendshipPayload constructor ( - public id: string, + public readonly id: string, ) { super() log.verbose('Friendship', 'constructor(id=%s)', id) diff --git a/src/user/room-invitation.ts b/src/user/room-invitation.ts index fbd4ba959..5f9ae15e1 100644 --- a/src/user/room-invitation.ts +++ b/src/user/room-invitation.ts @@ -55,7 +55,7 @@ export class RoomInvitation extends Accessory implements Acceptable { * */ constructor ( - public id: string, + public readonly id: string, ) { super() log.verbose('RoomInvitation', 'constructor(id=%s)', id) diff --git a/src/user/room.ts b/src/user/room.ts index c6d059fc1..965757b61 100644 --- a/src/user/room.ts +++ b/src/user/room.ts @@ -269,19 +269,15 @@ export class Room extends Accessory implements Sayable { */ protected payload?: RoomPayload - public readonly id: string // Room Id - /** * @private */ constructor ( - id: string, + public readonly id: string, ) { super() log.silly('Room', `constructor(${id})`) - this.id = id - // tslint:disable-next-line:variable-name const MyClass = instanceToClass(this, Room) -- GitLab