Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a9823890b | ||
|
|
e80b170fd1 | ||
|
|
76929a8763 |
@@ -161,11 +161,19 @@ function DesktopChromeSetting() {
|
||||
*/
|
||||
function AutostartSetting() {
|
||||
const [enabled, setEnabled] = useState(false);
|
||||
// [cinny-desktop #3] null until the native side answers (older builds don't
|
||||
// have the command, so the switch just stays hidden there).
|
||||
const [startMinimized, setStartMinimized] = useState<boolean | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
tauriInvoke()?.('plugin:autostart|is_enabled')
|
||||
.then((value) => setEnabled(value === true))
|
||||
.catch(() => undefined);
|
||||
tauriInvoke()?.('get_start_minimized')
|
||||
.then((value) => {
|
||||
if (typeof value === 'boolean') setStartMinimized(value);
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}, []);
|
||||
|
||||
const handleChange = (value: boolean) => {
|
||||
@@ -173,6 +181,11 @@ function AutostartSetting() {
|
||||
setEnabled(value);
|
||||
};
|
||||
|
||||
const handleStartMinimized = (value: boolean) => {
|
||||
invokeTauri('set_start_minimized', { value });
|
||||
setStartMinimized(value);
|
||||
};
|
||||
|
||||
if (!isTauriEnv()) return null;
|
||||
return (
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
@@ -181,6 +194,15 @@ function AutostartSetting() {
|
||||
description="Start Lotus Chat automatically when you sign in to your computer."
|
||||
after={<Switch variant="Primary" value={enabled} onChange={handleChange} />}
|
||||
/>
|
||||
{enabled && startMinimized !== null && (
|
||||
<SettingTile
|
||||
title="Start minimized"
|
||||
description="When it starts at login, keep Lotus Chat in the system tray instead of opening the window. Notifications still arrive; click the tray icon to open it."
|
||||
after={
|
||||
<Switch variant="Primary" value={startMinimized} onChange={handleStartMinimized} />
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</SequenceCard>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -363,9 +363,11 @@ const SOUNDCLOUD_PROFILE_TABS = new Set([
|
||||
export function isSoundCloudTrack(url: string): boolean {
|
||||
try {
|
||||
const { hostname, pathname } = new URL(url);
|
||||
// NOTE: on.soundcloud.com short links are NOT handled here — the w.soundcloud
|
||||
// widget resolver doesn't follow the redirect; supporting them needs an oEmbed
|
||||
// round-trip (soundcloud.com/oembed is CORS-enabled) to get the canonical URL.
|
||||
// on.soundcloud.com short links are not matched here (the w.soundcloud widget
|
||||
// doesn't follow the redirect), but they still embed: Synapse follows the
|
||||
// redirect when building the preview, and UrlPreviewCard's og:url fallback
|
||||
// re-parses the canonical soundcloud.com/<artist>/<track> URL (verified with
|
||||
// a real short link, Gitea #200).
|
||||
if (hostname.replace(/^www\./, '') !== 'soundcloud.com') return false;
|
||||
// /<artist>/<track|sets/set> — at least two segments, not a bare profile
|
||||
const parts = pathname
|
||||
|
||||
+13
-2
@@ -22,7 +22,14 @@ import { cleanupSearchCacheIfSignedOut } from './client/initMatrix';
|
||||
document.body.classList.add(configClass, varsClass);
|
||||
|
||||
// Register Service Worker
|
||||
if ('serviceWorker' in navigator) {
|
||||
// Service workers only register on http(s) pages. The desktop app loads from
|
||||
// `tauri://localhost` in debug builds (and on any platform where the localhost
|
||||
// plugin isn't used), where register() rejects: that surfaced in Sentry as an
|
||||
// unhandled "must be called with a script URL whose protocol is either HTTP or
|
||||
// HTTPS". Skip it there; the app works without a SW, only authenticated media
|
||||
// falls back to the client's own fetch.
|
||||
const swProtocolOk = window.location.protocol === 'https:' || window.location.protocol === 'http:';
|
||||
if ('serviceWorker' in navigator && swProtocolOk) {
|
||||
const swUrl =
|
||||
import.meta.env.MODE === 'production'
|
||||
? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js`
|
||||
@@ -39,7 +46,11 @@ if ('serviceWorker' in navigator) {
|
||||
// never route. Production sw.js is a classic bundled script.
|
||||
navigator.serviceWorker
|
||||
.register(swUrl, import.meta.env.MODE === 'production' ? undefined : { type: 'module' })
|
||||
.then(sendSessionToSW);
|
||||
.then(sendSessionToSW)
|
||||
.catch((err) => {
|
||||
// e.g. a private window with SWs disabled; the app still works.
|
||||
console.warn('Service worker registration failed', err);
|
||||
});
|
||||
navigator.serviceWorker.ready.then(sendSessionToSW);
|
||||
|
||||
navigator.serviceWorker.addEventListener('message', (ev) => {
|
||||
|
||||
Reference in New Issue
Block a user