Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
Checks / checks (push) Successful in 2m11s
Trigger cinny-mobile / dispatch (push) Successful in 1s

This commit is contained in:
2026-11-01 04:23:53 +11:00
parent 3cd159a63e
commit a6ad8651b3
605 changed files with 11480 additions and 9125 deletions
+44 -35
View File
@@ -4,11 +4,11 @@
*/
export const openExternalUrl = async (url: string): Promise<void> => {
console.log('[openExternalUrl] called with:', url);
// Use Electron's shell.openExternal if in Electron
if (isElectron()) {
try {
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.shell?.openExternal) {
await electron.shell.openExternal(url);
console.log('[openExternalUrl] Electron shell.openExternal succeeded');
@@ -18,7 +18,7 @@ export const openExternalUrl = async (url: string): Promise<void> => {
console.warn('[openExternalUrl] Electron shell.openExternal failed:', err);
}
}
// Use Tauri for actual Tauri builds
if (isTauri() && !isElectron()) {
try {
@@ -30,7 +30,7 @@ export const openExternalUrl = async (url: string): Promise<void> => {
return;
} catch (pluginErr) {
console.warn('[openExternalUrl] Tauri opener plugin failed:', pluginErr);
// Fallback: try the custom command (useful if plugin fails due to ACL)
try {
console.log('[openExternalUrl] trying Tauri invoke command fallback...');
@@ -43,7 +43,7 @@ export const openExternalUrl = async (url: string): Promise<void> => {
}
}
}
console.log('[openExternalUrl] falling back to window.open');
window.open(url, '_blank');
};
@@ -71,7 +71,7 @@ export const getYouTubeStream = async (url: string): Promise<YouTubeStreamInfo>
}
// Check for Electron
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.youtube?.getStream) {
const result = await electron.youtube.getStream(url);
// Electron returns { success: true, data: { video_url, title } } or { success: false, error }
@@ -100,7 +100,7 @@ export const isYouTubeStreamingAvailable = (): boolean => {
}
// Check for Electron
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.youtube?.getStream) {
return true;
}
@@ -137,7 +137,7 @@ export const focusWindow = async (): Promise<void> => {
// Use Electron's window focus if in Electron
if (isElectron()) {
try {
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.window?.focus) {
await electron.window.focus();
}
@@ -164,13 +164,15 @@ export const focusWindow = async (): Promise<void> => {
* Set up listener for notification tap/click actions
* Call this once at app startup with a navigation callback
*/
export const setupNotificationTapListener = async (onTap: (path: string) => void): Promise<void> => {
export const setupNotificationTapListener = async (
onTap: (path: string) => void,
): Promise<void> => {
notificationTapCallback = onTap;
// Use Electron's native notification handler if in Electron
if (isElectron()) {
try {
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.notification?.onNavigate) {
electron.notification.onNavigate((data: { path?: string }) => {
if (data.path && typeof data.path === 'string' && notificationTapCallback) {
@@ -184,16 +186,16 @@ export const setupNotificationTapListener = async (onTap: (path: string) => void
return;
}
}
// Use Tauri plugin for actual Tauri builds (not Electron)
if (isTauri() && !isElectron()) {
try {
const { onAction } = await import('@tauri-apps/plugin-notification');
await onAction(async (notification) => {
// Bring window to front first
await focusWindow();
// Get the path from extra data and navigate
const path = notification.notification?.extra?.path;
if (path && typeof path === 'string' && notificationTapCallback) {
@@ -208,13 +210,16 @@ export const setupNotificationTapListener = async (onTap: (path: string) => void
if (isCapacitorNative()) {
try {
const { LocalNotifications } = await importCapacitorLocalNotifications();
await LocalNotifications.addListener('localNotificationActionPerformed', async (event: any) => {
await focusWindow();
const path = event?.notification?.extra?.path;
if (path && typeof path === 'string' && notificationTapCallback) {
notificationTapCallback(path);
}
});
await LocalNotifications.addListener(
'localNotificationActionPerformed',
async (event: any) => {
await focusWindow();
const path = event?.notification?.extra?.path;
if (path && typeof path === 'string' && notificationTapCallback) {
notificationTapCallback(path);
}
},
);
} catch (err) {
console.warn('Failed to set up Capacitor notification tap listener:', err);
}
@@ -224,14 +229,12 @@ export const setupNotificationTapListener = async (onTap: (path: string) => void
/**
* Check if we're running inside a Tauri application
*/
export const isTauri = (): boolean =>
'__TAURI__' in window || '__TAURI_INTERNALS__' in window;
export const isTauri = (): boolean => '__TAURI__' in window || '__TAURI_INTERNALS__' in window;
/**
* Check if we're running inside Electron (not Tauri)
*/
export const isElectron = (): boolean =>
typeof window !== 'undefined' && 'electron' in window;
export const isElectron = (): boolean => typeof window !== 'undefined' && 'electron' in window;
/**
* Check if we're running inside a Capacitor native app
@@ -239,7 +242,11 @@ export const isElectron = (): boolean =>
export const isCapacitorNative = (): boolean => {
if (typeof window === 'undefined') return false;
const cap = (window as any).Capacitor;
return Boolean(cap?.isNativePlatform?.() || cap?.getPlatform?.() === 'android' || cap?.getPlatform?.() === 'ios');
return Boolean(
cap?.isNativePlatform?.() ||
cap?.getPlatform?.() === 'android' ||
cap?.getPlatform?.() === 'ios',
);
};
/**
@@ -327,7 +334,7 @@ const ensureNotificationChannel = async (): Promise<void> => {
try {
const { createChannel, Importance } = await import('@tauri-apps/plugin-notification');
await createChannel({
id: 'messages',
name: 'Messages',
@@ -336,7 +343,7 @@ const ensureNotificationChannel = async (): Promise<void> => {
vibration: true,
sound: 'default',
});
notificationChannelCreated = true;
} catch (err) {
console.warn('Failed to create notification channel:', err);
@@ -431,7 +438,7 @@ export const sendNotification = async (options: {
// Use Electron's native notification API if in Electron
if (isElectron()) {
try {
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.notification?.show) {
await electron.notification.show({
title,
@@ -511,7 +518,7 @@ export const sendNotification = async (options: {
console.warn('Capacitor notification failed:', err);
}
}
// Fallback to browser notification
sendBrowserNotification({ title, body, icon, onClick });
};
@@ -532,7 +539,7 @@ export const readClipboardImage = async (): Promise<File | null> => {
// Use Electron's clipboard API if in Electron
if (isElectron()) {
try {
const electron = (window as any).electron;
const { electron } = window as any;
if (electron?.clipboard?.readImage) {
const result = await electron.clipboard.readImage();
// IPC may return a data URL string or { success, data } depending on path.
@@ -543,7 +550,7 @@ export const readClipboardImage = async (): Promise<File | null> => {
? result.data
: null;
if (!dataUrl) return null;
// Convert data URL to File
const response = await fetch(dataUrl);
const blob = await response.blob();
@@ -561,7 +568,7 @@ export const readClipboardImage = async (): Promise<File | null> => {
try {
const { invoke } = await import('@tauri-apps/api/core');
const dataUrl = await invoke<string | null>('read_clipboard_image');
if (!dataUrl) return null;
// Convert data URL to File
@@ -574,7 +581,7 @@ export const readClipboardImage = async (): Promise<File | null> => {
return null;
}
}
return null;
};
@@ -593,7 +600,9 @@ export interface BackgroundSyncCredentials {
* Start background Matrix sync on mobile
* This runs the sync in native Rust code, allowing notifications even when the app is backgrounded
*/
export const startBackgroundSync = async (credentials: BackgroundSyncCredentials): Promise<void> => {
export const startBackgroundSync = async (
credentials: BackgroundSyncCredentials,
): Promise<void> => {
if (!isTauriMobile()) {
console.log('[BackgroundSync] Not on mobile, skipping');
return;