using Microsoft.JSInterop; namespace decePubClient.Services; public class AppStatusService { readonly IJSRuntime JsRuntime; readonly IJSInProcessRuntime JsSyncRuntime; public AppStatusService(IJSRuntime JSRuntime) { JsRuntime = JSRuntime; JsSyncRuntime = (IJSInProcessRuntime)JSRuntime; } public async ValueTask IsOnline() => await JsSyncRuntime.InvokeAsync("isOnline"); public bool InputCaptureSupported() => JsSyncRuntime.Invoke("inputCaptureSupported"); public bool IsServiceWorkerAvailable() => JsSyncRuntime.Invoke("isServiceWorkerAvailable"); public string Language() => JsSyncRuntime.Invoke("getLanguage"); public void Language(string language) => JsSyncRuntime.InvokeVoid("setLanguage", language); public long GetHeight(string classId) => JsSyncRuntime.Invoke("getHeight", classId); public void SetAppBadge(int counter) => JsSyncRuntime.InvokeVoid("setAppBadge", counter); public void ClearAppBadge() => JsSyncRuntime.InvokeVoid("clearAppBadge"); public async ValueTask ClearCache() { await JsRuntime.InvokeVoidAsync("clearCache"); } public async ValueTask ClearLocalStorage() { await JsRuntime.InvokeVoidAsync("clearLocalStorage"); } public void ReloadPage() { JsSyncRuntime.InvokeVoid("reloadPage"); } public bool IsMobileMedia() => JsSyncRuntime.Invoke("isMobileMedia"); public bool CanShare() => JsSyncRuntime.Invoke("canShareStuff"); public async ValueTask ShareTextUrl(string title, string text, Uri uri) => await JsRuntime.InvokeVoidAsync("shareTextUrl", title, text, uri.ToString()); public async ValueTask ShareText(string title, string text) => await JsRuntime.InvokeVoidAsync("shareText", title, text); }