The composer uploads each file as soon as it is attached (streamed from the browser file, under its own ten-minute
timeout), shows it uploading, processing (a 202 followed until ready), ready or failed with Retry, and cancels one
removed; publishing sends the ids, so a failed publish or a retried upload sends nothing twice. Size limits and types
come from /api/v2/instance, a file without a browser type gets one from its extension, and each refusal names the file
and why. Previews are 320 px thumbnails, not whole files in memory. A picture without a description is asked about once
("Publish anyway"; a setting turns it off), descriptions are sent with PUT, and an edit keeps the post's media, language
and sensitive flag.
Profile pictures are checked against the server's types and can be removed. A card shows "Media unavailable" with the
original's link when a picture fails, the blurhash behind a sensitive placeholder, and plays a GIF only on tap under
reduced motion. A failed export says so instead of downloading part of a file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
66 lines
2.8 KiB
C#
66 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using decePubClient.Models;
|
|
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace decePubClient.Services;
|
|
|
|
public class AppStatusService(IJSRuntime jsRuntime)
|
|
{
|
|
readonly IJSInProcessRuntime JsSyncRuntime = (IJSInProcessRuntime)jsRuntime;
|
|
|
|
public async ValueTask<bool> IsOnline(CancellationToken cancellationToken = default) =>
|
|
await jsRuntime.InvokeAsync<bool>("isOnline", cancellationToken);
|
|
|
|
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(CancellationToken cancellationToken = default) =>
|
|
await jsRuntime.InvokeVoidAsync("clearCache", cancellationToken);
|
|
|
|
public async ValueTask ClearLocalStorage(CancellationToken cancellationToken = default) =>
|
|
await jsRuntime.InvokeVoidAsync("clearLocalStorage", cancellationToken);
|
|
|
|
public void ReloadPage()
|
|
{
|
|
JsSyncRuntime.InvokeVoid("reloadPage");
|
|
}
|
|
|
|
// wwwroot/js/theme.js
|
|
public void ApplyTheme(PageSettings pageSettings) => JsSyncRuntime.InvokeVoid("neoTheme.apply", pageSettings);
|
|
|
|
public bool IsDarkTheme() => JsSyncRuntime.Invoke<bool>("neoTheme.isDark");
|
|
|
|
public bool IsMobileMedia() => JsSyncRuntime.Invoke<bool>("isMobileMedia");
|
|
|
|
// whether the navigation being decided came from the Back (or Forward) button
|
|
public bool TookBack() => JsSyncRuntime.Invoke<bool>("tookBack");
|
|
|
|
// whether the pointer can hover (a mouse); a touch screen can't, so what shows on hover there opens on a tap
|
|
public bool CanHover() => JsSyncRuntime.Invoke<bool>("canHover");
|
|
|
|
// read once: a card asks it for each gifv it shows
|
|
bool? reducedMotion;
|
|
|
|
public bool PrefersReducedMotion() => reducedMotion ??= JsSyncRuntime.Invoke<bool>("prefersReducedMotion");
|
|
|
|
// a sideways-scrolling strip of tabs shows its selected tab
|
|
public void RevealActive(ElementReference strip) => JsSyncRuntime.InvokeVoid("revealActive", strip);
|
|
|
|
public bool CanShare() => JsSyncRuntime.Invoke<bool>("canShareStuff");
|
|
|
|
public async ValueTask ShareTextUrl(string title, string text, Uri uri, CancellationToken cancellationToken = default) =>
|
|
await jsRuntime.InvokeVoidAsync("shareTextUrl", cancellationToken, title, text, uri.ToString());
|
|
|
|
public async ValueTask ShareText(string title, string text, CancellationToken cancellationToken = default) =>
|
|
await jsRuntime.InvokeVoidAsync("shareText", cancellationToken, title, text);
|
|
} |