[frontend] Add EmojiService
This commit is contained in:
parent
42c860f579
commit
47bda1428b
2 changed files with 30 additions and 0 deletions
29
Iceshrimp.Frontend/Core/Services/EmojiService.cs
Normal file
29
Iceshrimp.Frontend/Core/Services/EmojiService.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using Iceshrimp.Frontend.Core.Miscellaneous;
|
||||
using Iceshrimp.Shared.Schemas;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Iceshrimp.Frontend.Core.Services;
|
||||
|
||||
internal class EmojiService(ApiService api)
|
||||
{
|
||||
[Inject] private ApiService Api { get; set; } = api;
|
||||
private List<EmojiResponse>? Emojis { get; set; }
|
||||
|
||||
public async Task<List<EmojiResponse>> GetEmoji()
|
||||
{
|
||||
if (Emojis is not null) return Emojis;
|
||||
try
|
||||
{
|
||||
var emoji = await Api.Emoji.GetAllEmoji();
|
||||
Emojis = emoji;
|
||||
return Emojis;
|
||||
}
|
||||
catch (ApiException)
|
||||
{
|
||||
// FIXME: Implement connection error handling
|
||||
throw new Exception("Failed to fetch emoji");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ builder.Services.AddSingleton<StreamingService>();
|
|||
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthStateProvider>();
|
||||
builder.Services.AddSingleton<ComposeService>();
|
||||
builder.Services.AddSingleton<StateService>();
|
||||
builder.Services.AddSingleton<EmojiService>();
|
||||
builder.Services.AddAuthorizationCore();
|
||||
builder.Services.AddCascadingAuthenticationState();
|
||||
builder.Services.AddBlazoredLocalStorageAsSingleton();
|
||||
|
|
Loading…
Add table
Reference in a new issue