fix mention bug
This commit is contained in:
parent
06d142c4a5
commit
c2812fae43
|
@ -225,7 +225,7 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
// this.status = state;
|
// this.status = state;
|
||||||
// } else {
|
// } else {
|
||||||
if (!this.status || this.status === '') {
|
if (!this.status || this.status === '') {
|
||||||
const uniqueMentions = this.getMentions(this.statusReplyingTo, this.statusReplyingToWrapper.provider);
|
const uniqueMentions = this.getMentions(this.statusReplyingTo);
|
||||||
for (const mention of uniqueMentions) {
|
for (const mention of uniqueMentions) {
|
||||||
this.status += `@${mention} `;
|
this.status += `@${mention} `;
|
||||||
}
|
}
|
||||||
|
@ -492,8 +492,20 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
return cwLength;
|
return cwLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getMentions(status: Status, providerInfo: AccountInfo): string[] {
|
private getMentions(status: Status): string[] {
|
||||||
const mentions = [status.account.acct, ...status.mentions.map(x => x.acct)];
|
let acct = status.account.acct;
|
||||||
|
if(!acct.includes('@')) {
|
||||||
|
acct += `@${status.account.url.replace('https://', '').split('/')[0]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const mentions = [acct];
|
||||||
|
status.mentions.forEach(m => {
|
||||||
|
let mentionAcct = m.acct;
|
||||||
|
if(!mentionAcct.includes('@')){
|
||||||
|
mentionAcct += `@${m.url.replace('https://', '').split('/')[0]}`;
|
||||||
|
}
|
||||||
|
mentions.push(mentionAcct);
|
||||||
|
});
|
||||||
|
|
||||||
let uniqueMentions = [];
|
let uniqueMentions = [];
|
||||||
for (let mention of mentions) {
|
for (let mention of mentions) {
|
||||||
|
@ -502,22 +514,10 @@ export class CreateStatusComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let globalUniqueMentions = [];
|
|
||||||
for (let mention of uniqueMentions) {
|
|
||||||
if (!mention.includes('@')) {
|
|
||||||
if (providerInfo) {
|
|
||||||
mention += `@${providerInfo.instance}`;
|
|
||||||
} else {
|
|
||||||
mention += `@${status.url.replace('https://', '').split('/')[0]}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
globalUniqueMentions.push(mention);
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedUser = this.toolsService.getSelectedAccounts()[0];
|
const selectedUser = this.toolsService.getSelectedAccounts()[0];
|
||||||
globalUniqueMentions = globalUniqueMentions.filter(x => x.toLowerCase() !== `${selectedUser.username}@${selectedUser.instance}`.toLowerCase());
|
uniqueMentions = uniqueMentions.filter(x => x.toLowerCase() !== `${selectedUser.username}@${selectedUser.instance}`.toLowerCase());
|
||||||
|
|
||||||
return globalUniqueMentions;
|
return uniqueMentions;
|
||||||
}
|
}
|
||||||
|
|
||||||
onCtrlEnter(): boolean {
|
onCtrlEnter(): boolean {
|
||||||
|
|
Loading…
Reference in New Issue