[frontend/components] Add refetch note action to note footer menu
This commit is contained in:
parent
7ebcb98dd5
commit
316c25e036
2 changed files with 38 additions and 0 deletions
|
@ -93,6 +93,12 @@
|
||||||
<Text>@Loc["Bite"]</Text>
|
<Text>@Loc["Bite"]</Text>
|
||||||
</MenuElement>
|
</MenuElement>
|
||||||
}
|
}
|
||||||
|
@if (Note.User.Host != null)
|
||||||
|
{
|
||||||
|
<MenuElement Icon="Icons.ArrowsClockwise" OnSelect="RefetchNote">
|
||||||
|
<Text>@Loc["Refetch"]</Text>
|
||||||
|
</MenuElement>
|
||||||
|
}
|
||||||
<MenuElement Icon="Icons.SpeakerX" OnSelect="Mute">
|
<MenuElement Icon="Icons.SpeakerX" OnSelect="Mute">
|
||||||
<Text>@Loc["Mute thread"]</Text>
|
<Text>@Loc["Mute thread"]</Text>
|
||||||
</MenuElement>
|
</MenuElement>
|
||||||
|
@ -211,4 +217,13 @@
|
||||||
{
|
{
|
||||||
_ = NoteActions.MuteAsync(Note);
|
_ = NoteActions.MuteAsync(Note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task RefetchNote() =>
|
||||||
|
await GlobalComponentSvc.ConfirmDialog?.Confirm(new EventCallback<bool>(this, RefetchNoteCallback), Loc["Refetch note?"])!;
|
||||||
|
|
||||||
|
private async Task RefetchNoteCallback(bool refetch)
|
||||||
|
{
|
||||||
|
if (!refetch) return;
|
||||||
|
await NoteActions.RefetchRemoteNoteAsync(Note.Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,29 @@ internal class NoteActions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task RefetchRemoteNoteAsync(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var res = await api.Notes.RefetchNoteAsync(id);
|
||||||
|
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
if (res.Errors.Count != 0)
|
||||||
|
{
|
||||||
|
logger.LogError($"Failed to refetch note. {string.Join(", ", res.Errors)}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Broadcast(res.Note);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ApiException e)
|
||||||
|
{
|
||||||
|
logger.LogError(e, "Failed to refetch note.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task ToggleLikeAsync(NoteBase note)
|
public async Task ToggleLikeAsync(NoteBase note)
|
||||||
{
|
{
|
||||||
if (note.Liked)
|
if (note.Liked)
|
||||||
|
|
Loading…
Add table
Reference in a new issue