54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
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<bool> IsOnline() => await JsSyncRuntime.InvokeAsync<bool>("isOnline");
|
|
|
|
public bool InputCaptureSupported() => JsSyncRuntime.Invoke<bool>("inputCaptureSupported");
|
|
|
|
public bool IsServiceWorkerAvailable() => JsSyncRuntime.Invoke<bool>("isServiceWorkerAvailable");
|
|
|
|
public string Language() => JsSyncRuntime.Invoke<string>("getLanguage");
|
|
|
|
public void Language(string language) => JsSyncRuntime.InvokeVoid("setLanguage", language);
|
|
|
|
public long GetHeight(string classId) => JsSyncRuntime.Invoke<long>("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<bool>("isMobileMedia");
|
|
|
|
public bool CanShare() => JsSyncRuntime.Invoke<bool>("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);
|
|
} |