提交 f906d7a5 编写于 作者: H hcz 提交者: Huan (李卓桓)

update(doc): add TODOs (#640)

上级 a1d366e1
......@@ -104,6 +104,9 @@ export class Contact implements Sayable {
private dirtyObj: ContactObj | null
private rawObj: ContactRawObj
/**
* @private
*/
constructor(
public readonly id: string,
) {
......
......@@ -244,6 +244,9 @@ export class Message implements Sayable {
throw Error('not a media message')
}
/**
* @private
*/
constructor(public rawObj?: MsgRawObj) {
this._counter = Message.counter++
log.silly('Message', 'constructor() SN:%d', this._counter)
......@@ -315,6 +318,9 @@ export class Message implements Sayable {
return '{' + this.type() + '}' + content
}
/**
* @todo document me
*/
public from(contact: Contact): void
public from(id: string): void
public from(): Contact
......@@ -340,6 +346,9 @@ export class Message implements Sayable {
// public to(room: Room): void
// public to(): Contact|Room
// public to(contact?: Contact|Room|string): Contact|Room|void {
/**
* @todo document me
*/
public to(contact: Contact): void
public to(id: string): void
public to(): Contact|null // if to is not set, then room must had set
......@@ -364,6 +373,9 @@ export class Message implements Sayable {
return Contact.load(this.obj.to)
}
/**
* @todo document me
*/
public room(room: Room): void
public room(id: string): void
public room(): Room|null
......@@ -384,6 +396,9 @@ export class Message implements Sayable {
return null
}
/**
* @todo document me
*/
public content(): string
public content(content: string): void
......@@ -395,10 +410,16 @@ export class Message implements Sayable {
return this.obj.content
}
/**
* @todo document me
*/
public type(): MsgType {
return this.obj.type
}
/**
* @todo document me
*/
public typeSub(): MsgType {
if (!this.rawObj) {
throw new Error('no rawObj')
......@@ -406,6 +427,9 @@ export class Message implements Sayable {
return this.rawObj.SubMsgType
}
/**
* @todo document me
*/
public typeApp(): AppMsgType {
if (!this.rawObj) {
throw new Error('no rawObj')
......@@ -413,9 +437,18 @@ export class Message implements Sayable {
return this.rawObj.AppMsgType
}
/**
* @todo document me
*/
public typeEx() { return MsgType[this.obj.type] }
/**
* @todo document me
*/
public count() { return this._counter }
/**
* @todo document me
*/
public self(): boolean {
const userId = config.puppetInstance()
.userId
......@@ -579,6 +612,9 @@ export class Message implements Sayable {
// })
// }
/**
* @todo document me
*/
public say(text: string, replyTo?: Contact | Contact[]): Promise<any>
public say(mediaMessage: MediaMessage, replyTo?: Contact | Contact[]): Promise<any>
......@@ -736,6 +772,9 @@ export class MediaMessage extends Message {
}
}
/**
* @todo document me
*/
public ext(): string {
if (this.fileExt)
return this.fileExt
......@@ -770,6 +809,9 @@ export class MediaMessage extends Message {
throw new Error('not support type: ' + this.type())
}
/**
* @todo document me
*/
public filename(): string {
if (this.fileName && this.fileExt) {
return this.fileName + '.' + this.fileExt
......
......@@ -92,11 +92,17 @@ export class Room extends EventEmitter implements Sayable {
private obj: RoomObj | null
private rawObj: RoomRawObj
/**
* @private
*/
constructor(public id: string) {
super()
log.silly('Room', `constructor(${id})`)
}
/**
* @private
*/
public toString() { return this.id }
public toStringEx() { return `Room(${this.obj && this.obj.topic}[${this.id}])` }
......@@ -104,6 +110,9 @@ export class Room extends EventEmitter implements Sayable {
return !!(this.obj && this.obj.memberList && this.obj.memberList.length)
}
/**
* @todo document me
*/
public async refresh(): Promise<void> {
if (this.isReady()) {
this.dirtyObj = this.obj
......@@ -161,11 +170,25 @@ export class Room extends EventEmitter implements Sayable {
}
}
/**
* @todo document me
*/
public on(event: 'leave', listener: (this: Room, leaver: Contact) => void): this
/**
* @todo document me
*/
public on(event: 'join' , listener: (this: Room, inviteeList: Contact[] , inviter: Contact) => void): this
/**
* @todo document me
*/
public on(event: 'topic', listener: (this: Room, topic: string, oldTopic: string, changer: Contact) => void): this
/**
* @todo document me
*/
public on(event: 'EVENT_PARAM_ERROR', listener: () => void): this
/**
* @todo document me
*/
public on(event: RoomEventName, listener: (...args: any[]) => any): this {
log.verbose('Room', 'on(%s, %s)', event, typeof listener)
......@@ -173,6 +196,9 @@ export class Room extends EventEmitter implements Sayable {
return this
}
/**
* @todo document me
*/
public say(mediaMessage: MediaMessage)
public say(content: string)
public say(content: string, replyTo: Contact)
......@@ -212,6 +238,9 @@ export class Room extends EventEmitter implements Sayable {
public get(prop): string { return (this.obj && this.obj[prop]) || (this.dirtyObj && this.dirtyObj[prop]) }
/**
* @private
*/
private parse(rawObj: RoomRawObj): RoomObj | null {
if (!rawObj) {
log.warn('Room', 'parse() on a empty rawObj?')
......@@ -278,6 +307,9 @@ export class Room extends EventEmitter implements Sayable {
Object.keys(this.obj).forEach(k => console.error(`${k}: ${this.obj && this.obj[k]}`))
}
/**
* @todo document me
*/
public async add(contact: Contact): Promise<number> {
log.verbose('Room', 'add(%s)', contact)
......@@ -290,6 +322,9 @@ export class Room extends EventEmitter implements Sayable {
return n
}
/**
* @todo document me
*/
public async del(contact: Contact): Promise<number> {
log.verbose('Room', 'del(%s)', contact.name())
......@@ -302,6 +337,9 @@ export class Room extends EventEmitter implements Sayable {
return n
}
/**
* @todo document me
*/
private delLocal(contact: Contact): number {
log.verbose('Room', 'delLocal(%s)', contact)
......@@ -379,6 +417,9 @@ export class Room extends EventEmitter implements Sayable {
return this.roomAlias(contact)
}
/**
* @todo document me
*/
public roomAlias(contact: Contact): string | null {
if (!this.obj || !this.obj.roomAliasMap) {
return null
......@@ -386,6 +427,9 @@ export class Room extends EventEmitter implements Sayable {
return this.obj.roomAliasMap[contact.id] || null
}
/**
* @todo document me
*/
public has(contact: Contact): boolean {
if (!this.obj || !this.obj.memberList) {
return false
......@@ -395,6 +439,9 @@ export class Room extends EventEmitter implements Sayable {
.length > 0
}
/**
* @todo document me
*/
public owner(): Contact | null {
const ownerUin = this.obj && this.obj.ownerUin
......@@ -499,6 +546,9 @@ export class Room extends EventEmitter implements Sayable {
}
}
/**
* @todo document me
*/
public member(name: string): Contact | null
public member(filter: MemberQueryFilter): Contact | null
......@@ -524,6 +574,9 @@ export class Room extends EventEmitter implements Sayable {
return memberList[0]
}
/**
* @todo document me
*/
public memberList(): Contact[] {
log.verbose('Room', 'memberList')
......@@ -538,6 +591,9 @@ export class Room extends EventEmitter implements Sayable {
return this.obj.memberList
}
/**
* @todo document me
*/
public static create(contactList: Contact[], topic?: string): Promise<Room> {
log.verbose('Room', 'create(%s, %s)', contactList.join(','), topic)
......@@ -554,6 +610,9 @@ export class Room extends EventEmitter implements Sayable {
})
}
/**
* @todo document me
*/
public static async findAll(query?: RoomQueryFilter): Promise<Room[]> {
if (!query) {
query = { topic: /.*/ }
......
......@@ -170,6 +170,9 @@ export class Wechaty extends EventEmitter implements Sayable {
return config.npmVersion()
}
/**
* @todo document me
*/
public version(forceNpm?) {
return Wechaty.version(forceNpm)
}
......@@ -281,7 +284,6 @@ export class Wechaty extends EventEmitter implements Sayable {
/**
* @todo document me
*/
public on(event: WechatyEventName, listener: (...args: any[]) => any): this {
log.verbose('Wechaty', 'addListener(%s, %s)', event, typeof listener)
......@@ -447,7 +449,6 @@ export class Wechaty extends EventEmitter implements Sayable {
/**
* @todo document me
* @static
*
*/
public static async sleep(millisecond: number): Promise<void> {
await new Promise(resolve => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册