[frontend/components] Don't get emojis until opening emoji picker

This commit is contained in:
pancakes 2025-03-27 01:18:11 +10:00
parent 1c7f2832a1
commit ac47bafffd
No known key found for this signature in database
4 changed files with 13 additions and 9 deletions

View file

@ -512,9 +512,9 @@
}
}
private void ToggleEmojiPicker()
private async Task ToggleEmojiPicker()
{
GlobalComponentSvc.EmojiPicker?.Open(EmojiButton, new EventCallback<EmojiResponse>(this, AddEmoji));
await GlobalComponentSvc.EmojiPicker?.Open(EmojiButton, new EventCallback<EmojiResponse>(this, AddEmoji))!;
}
private async Task AddQuote() =>

View file

@ -44,10 +44,8 @@
protected override async Task OnInitializedAsync()
{
GlobalComponentSvc.EmojiPicker = this;
EmojiList = await EmojiService.GetEmojiAsync();
_module = (IJSInProcessObjectReference)await Js.InvokeAsync<IJSObjectReference>("import",
"./Components/EmojiPicker.razor.js");
FilterEmojis();
}
private async Task Select(EmojiResponse emoji)
@ -61,8 +59,14 @@
_module.InvokeVoid("closeDialog", EmojiPickerRef);
}
public void Open(ElementReference root, EventCallback<EmojiResponse> func)
public async Task Open(ElementReference root, EventCallback<EmojiResponse> func)
{
if (EmojiList.Count == 0)
{
EmojiList = await EmojiService.GetEmojiAsync();
FilterEmojis();
}
OnEmojiSelect = func;
var pos = _module.Invoke<List<float>>("getPosition", root);
_left = pos[0];

View file

@ -193,9 +193,9 @@
NoteActions.DoQuote(Note);
}
private void ToggleEmojiPicker()
private async Task ToggleEmojiPicker()
{
GlobalComponentSvc.EmojiPicker?.Open(EmojiButton, new EventCallback<EmojiResponse>(this, React));
await GlobalComponentSvc.EmojiPicker?.Open(EmojiButton, new EventCallback<EmojiResponse>(this, React))!;
}
private void React(EmojiResponse emoji)

View file

@ -312,9 +312,9 @@
UserProfile.BannerAlt = "";
}
private void ToggleEmojiPicker()
private async Task ToggleEmojiPicker()
{
GlobalComponentSvc.EmojiPicker?.Open(EmojiButton, new EventCallback<EmojiResponse>(this, AddEmoji));
await GlobalComponentSvc.EmojiPicker?.Open(EmojiButton, new EventCallback<EmojiResponse>(this, AddEmoji))!;
}
private async Task AddEmoji(EmojiResponse emoji)