···11-export function openDialog(element) {
22- element.showModal()
33-}
44-55-export function closeDialog(element) {
66- element.close()
77-}
+16
Iceshrimp.Frontend/Core/Services/JsService.cs
···11+using Microsoft.AspNetCore.Components;
22+using Microsoft.JSInterop;
33+44+namespace Iceshrimp.Frontend.Core.Services;
55+66+/// <summary>
77+/// This service is used to wrap any calls to JS interop for functionality that is used in multiple places around the frontend (e.g. showing/closing a dialog)
88+/// </summary>
99+public class JsService
1010+{
1111+ public IJSObjectReference? Module { private get; set; }
1212+1313+ public ValueTask ShowDialogAsync(ElementReference dialog) => Module!.InvokeVoidAsync("showDialog", dialog);
1414+1515+ public ValueTask CloseDialogAsync(ElementReference dialog, string? returnValue = null) => Module!.InvokeVoidAsync("closeDialog", dialog, returnValue);
1616+}
···11+/**
22+ * Displays a dialog
33+ * @param {HTMLDialogElement} dialog Element reference
44+ */
55+export function showDialog(dialog) {
66+ dialog.showModal();
77+}
88+99+/**
1010+ * Close a dialog
1111+ * @param {HTMLDialogElement} dialog Element reference
1212+ * @param {string?} returnValue Value to set for
1313+ */
1414+export function closeDialog(dialog, returnValue) {
1515+ dialog.close(returnValue);
1616+}