make sure all mentions are global (multi-account issue)

This commit is contained in:
Nicolas Constant 2019-03-05 23:00:06 -05:00
parent ac5092aa76
commit 227fc556b6
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 16 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import { Status } from '../../services/models/mastodon.interfaces';
import { ToolsService } from '../../services/tools.service';
import { NotificationService } from '../../services/notification.service';
import { StatusWrapper } from '../../models/common.model';
import { AccountInfo } from 'src/app/states/accounts.state';
@Component({
selector: 'app-create-status',
@ -47,7 +48,7 @@ export class CreateStatusComponent implements OnInit {
// }
// }
const uniqueMentions = this.getMentions(this.statusReplyingTo);
const uniqueMentions = this.getMentions(this.statusReplyingTo, this.statusReplyingToWrapper.provider);
for (const mention of uniqueMentions) {
this.status += `@${mention} `;
}
@ -58,18 +59,25 @@ export class CreateStatusComponent implements OnInit {
}, 0);
}
private getMentions(status: Status): string[]{
private getMentions(status: Status, providerInfo: AccountInfo): string[]{
const mentions = [...status.mentions.map(x => x.acct), status.account.acct];
let uniqueMentions = [];
for(let mention of mentions){
if(!uniqueMentions.includes(mention)){
// if(!mention.includes('@')){
// mention += `@${status.}`;
// }
if(!uniqueMentions.includes(mention)){
uniqueMentions.push(mention);
}
}
return uniqueMentions;
}
let globalUniqueMentions = [];
for(let mention of uniqueMentions){
if(!mention.includes('@')){
mention += `@${providerInfo.instance}`;
}
globalUniqueMentions.push(mention);
}
return globalUniqueMentions;
}
onSubmit(): boolean {