-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: room mention contact should using roomAlias https://github.com/Chatie/wechaty/issues/1604 #1607
fix: room mention contact should using roomAlias https://github.com/Chatie/wechaty/issues/1604 #1607
Changes from 4 commits
7c65207
0d35549
b04fc91
4abc8ce
3dc4b0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,23 +428,33 @@ export class Room extends Accessory implements Sayable { | |
textOrContactOrFileOrUrl : string | Contact | FileBox | UrlLink, | ||
mention? : Contact | Contact[], | ||
): Promise<void> { | ||
|
||
const replyToList: Contact[] = [].concat(mention as any || []) | ||
|
||
const mentionAliasPromiseList = replyToList.length > 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe Rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mentionAliasPromiseList may contain |
||
? await Promise.all( | ||
replyToList | ||
.map(c => this.alias(c) || c.name())) | ||
: [] | ||
|
||
const mentionAliasList: string[] = mentionAliasPromiseList | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed because the array should not include the null anymore after the above code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but it is possible promise fail and got null value for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
However, you can keep this code and I'll have a look after we merged it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
.filter(a => a !== null) as string[] | ||
|
||
log.verbose('Room', 'say(%s, %s)', | ||
textOrContactOrFileOrUrl, | ||
Array.isArray(mention) | ||
? mention.map(c => c.name()).join(', ') | ||
: mention ? mention.name() : '', | ||
) | ||
let text: string | ||
mentionAliasList.length > 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
? mentionAliasList.join(', ') | ||
: mentionAliasList.length === 1 ? mentionAliasList[0] : '') | ||
|
||
const replyToList: Contact[] = [].concat(mention as any || []) | ||
let text: string | ||
|
||
if (typeof textOrContactOrFileOrUrl === 'string') { | ||
|
||
if (replyToList.length > 0) { | ||
if (mentionAliasList.length > 0) { | ||
// const AT_SEPRATOR = String.fromCharCode(8197) | ||
const AT_SEPRATOR = FOUR_PER_EM_SPACE | ||
const mentionList = replyToList.map(roomAlias => '@' + roomAlias).join(AT_SEPRATOR) | ||
|
||
const mentionList = replyToList.map(c => '@' + c.name()).join(AT_SEPRATOR) | ||
text = mentionList + ' ' + textOrContactOrFileOrUrl | ||
} else { | ||
text = textOrContactOrFileOrUrl | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
[...mention]
should be better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the replyToList is original code, and what if mention is undefine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...(undefined||[])]