[frontend/components] Don't mention yourself or local host part when composing replies (ISH-603)
This commit is contained in:
parent
11575e4daf
commit
b581714387
1 changed files with 6 additions and 5 deletions
|
@ -10,6 +10,7 @@
|
||||||
@inject ApiService ApiService
|
@inject ApiService ApiService
|
||||||
@inject ComposeService ComposeService
|
@inject ComposeService ComposeService
|
||||||
@inject SessionService SessionService
|
@inject SessionService SessionService
|
||||||
|
@inject MetadataService MetadataService
|
||||||
@inject IStringLocalizer<Localization> Loc;
|
@inject IStringLocalizer<Localization> Loc;
|
||||||
@inject GlobalComponentSvc GlobalComponentSvc
|
@inject GlobalComponentSvc GlobalComponentSvc
|
||||||
@inject MessageService MessageService
|
@inject MessageService MessageService
|
||||||
|
@ -157,7 +158,7 @@
|
||||||
{
|
{
|
||||||
if (replyTo != null)
|
if (replyTo != null)
|
||||||
{
|
{
|
||||||
var mentions = EnumerateMentions(replyTo);
|
var mentions = await EnumerateMentions(replyTo);
|
||||||
ResetState();
|
ResetState();
|
||||||
ReplyOrQuote = replyTo;
|
ReplyOrQuote = replyTo;
|
||||||
NoteDraft.ReplyId = replyTo.Id;
|
NoteDraft.ReplyId = replyTo.Id;
|
||||||
|
@ -189,7 +190,7 @@
|
||||||
await _module.InvokeVoidAsync("openDialog", Dialog);
|
await _module.InvokeVoidAsync("openDialog", Dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> EnumerateMentions(NoteBase noteBase)
|
private async Task<List<string>> EnumerateMentions(NoteBase noteBase)
|
||||||
{
|
{
|
||||||
List<string> mentions = [];
|
List<string> mentions = [];
|
||||||
if (noteBase.User.Id != SessionService.Current!.Id)
|
if (noteBase.User.Id != SessionService.Current!.Id)
|
||||||
|
@ -203,18 +204,18 @@
|
||||||
mentions.Add(userMention);
|
mentions.Add(userMention);
|
||||||
}
|
}
|
||||||
|
|
||||||
var current = $"@{SessionService.Current.Username}@{SessionService.Current.Host}";
|
var instance = await MetadataService.Instance.Value;
|
||||||
var mfmNodes = noteBase.Text != null ? Mfm.parse(noteBase.Text) : [];
|
var mfmNodes = noteBase.Text != null ? Mfm.parse(noteBase.Text) : [];
|
||||||
foreach (var node in mfmNodes)
|
foreach (var node in mfmNodes)
|
||||||
{
|
{
|
||||||
if (node is MfmNodeTypes.MfmMentionNode mentionNode)
|
if (node is MfmNodeTypes.MfmMentionNode mentionNode)
|
||||||
{
|
{
|
||||||
mentions.Add(mentionNode.Acct);
|
mentions.Add(mentionNode.Acct.Replace($"@{instance.AccountDomain}", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mentions = mentions.Distinct().ToList();
|
mentions = mentions.Distinct().ToList();
|
||||||
mentions.Remove(current);
|
mentions.Remove(SessionService.Current.Username);
|
||||||
return mentions;
|
return mentions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue