♻️ No idea, but errors all gone
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DysonNetwork.Shared.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace DysonNetwork.Sphere.Connection;
|
||||
|
||||
[ApiController]
|
||||
[Route("completion")]
|
||||
public class AutoCompletionController(AppDatabase db)
|
||||
public class AutoCompletionController(IAccountService accounts, AppDatabase db)
|
||||
: ControllerBase
|
||||
{
|
||||
[HttpPost]
|
||||
@@ -38,19 +39,15 @@ public class AutoCompletionController(AppDatabase db)
|
||||
|
||||
private async Task<List<CompletionItem>> GetAccountCompletions(string searchTerm)
|
||||
{
|
||||
return await db.Accounts
|
||||
.Where(a => EF.Functions.ILike(a.Name, $"%{searchTerm}%"))
|
||||
.OrderBy(a => a.Name)
|
||||
.Take(10)
|
||||
.Select(a => new CompletionItem
|
||||
{
|
||||
Id = a.Id.ToString(),
|
||||
DisplayName = a.Name,
|
||||
SecondaryText = a.Nick,
|
||||
Type = "account",
|
||||
Data = a
|
||||
})
|
||||
.ToListAsync();
|
||||
var data = await accounts.SearchAccountsAsync(searchTerm);
|
||||
return data.Select(a => new CompletionItem
|
||||
{
|
||||
Id = a.Id.ToString(),
|
||||
DisplayName = a.Name,
|
||||
SecondaryText = a.Nick,
|
||||
Type = "account",
|
||||
Data = a
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
private async Task<List<CompletionItem>> GetStickerCompletions(string searchTerm)
|
||||
|
||||
Reference in New Issue
Block a user