Iceshrimp.NET/Iceshrimp.Frontend/Core/Services/EmojiService.cs
2024-11-20 00:48:29 +01:00

27 lines
No EOL
675 B
C#

using Iceshrimp.Frontend.Core.Miscellaneous;
using Iceshrimp.Shared.Schemas.Web;
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>> GetEmojiAsync()
{
if (Emojis is not null) return Emojis;
try
{
var emoji = await Api.Emoji.GetAllEmojiAsync();
Emojis = emoji;
return Emojis;
}
catch (ApiException)
{
// FIXME: Implement connection error handling
throw new Exception("Failed to fetch emoji");
}
}
}