Drop the dead Tauri branches and the plugin packages. [skip build]
Checks / checks (push) Successful in 2m43s
Trigger cinny-mobile / dispatch (push) Successful in 1s

This commit is contained in:
2026-11-01 05:31:13 +11:00
parent 0f60822cec
commit d6fe94ff48
7 changed files with 7 additions and 354 deletions
+4 -140
View File
@@ -1,5 +1,5 @@
/**
* Open an external URL using Tauri opener plugin on desktop/mobile, or window.open in browser
* Open an external URL using Electron's shell.openExternal, or window.open in browser
* @param url The URL to open
*/
export const openExternalUrl = async (url: string): Promise<void> => {
@@ -19,31 +19,6 @@ export const openExternalUrl = async (url: string): Promise<void> => {
}
}
// Use Tauri for actual Tauri builds
if (isTauri() && !isElectron()) {
try {
// First, try the plugin directly (works on both desktop and mobile)
console.log('[openExternalUrl] trying Tauri opener plugin...');
const { openUrl } = await import('@tauri-apps/plugin-opener');
await openUrl(url);
console.log('[openExternalUrl] Tauri plugin succeeded');
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...');
const { invoke } = await import('@tauri-apps/api/core');
await invoke('open_external_url', { url });
console.log('[openExternalUrl] Tauri command fallback succeeded');
return;
} catch (invokeErr) {
console.error('[openExternalUrl] Tauri command fallback also failed:', invokeErr);
}
}
}
console.log('[openExternalUrl] falling back to window.open');
window.open(url, '_blank');
};
@@ -131,7 +106,7 @@ const importCapacitorLocalNotifications = async (): Promise<CapacitorLocalNotifi
import(/* @vite-ignore */ CAPACITOR_LOCAL_NOTIFICATIONS_MODULE_ID);
/**
* Bring the Tauri window to the front and focus it
* Bring the app window to the front and focus it
*/
export const focusWindow = async (): Promise<void> => {
// Use Electron's window focus if in Electron
@@ -146,18 +121,6 @@ export const focusWindow = async (): Promise<void> => {
console.warn('Failed to focus Electron window:', err);
}
}
// Use Tauri's window focus for actual Tauri builds
if (isTauri() && !isElectron()) {
try {
const { getCurrentWindow } = await import('@tauri-apps/api/window');
const window = getCurrentWindow();
await window.unminimize();
await window.setFocus();
} catch (err) {
console.warn('Failed to focus Tauri window:', err);
}
}
};
/**
@@ -187,26 +150,6 @@ export const setupNotificationTapListener = async (
}
}
// 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) {
notificationTapCallback(path);
}
});
} catch (err) {
console.warn('Failed to set up Tauri notification tap listener:', err);
}
}
if (isCapacitorNative()) {
try {
const { LocalNotifications } = await importCapacitorLocalNotifications();
@@ -325,31 +268,6 @@ const sendBrowserNotification = (options: {
/** Flag to track if notification channel has been created on Android */
let notificationChannelCreated = false;
/**
* Create notification channel for Android
* Required for Android 8.0+ to show notifications
*/
const ensureNotificationChannel = async (): Promise<void> => {
if (notificationChannelCreated || !isAndroid()) return;
try {
const { createChannel, Importance } = await import('@tauri-apps/plugin-notification');
await createChannel({
id: 'messages',
name: 'Messages',
description: 'Message notifications from Matrix',
importance: Importance.High,
vibration: true,
sound: 'default',
});
notificationChannelCreated = true;
} catch (err) {
console.warn('Failed to create notification channel:', err);
}
};
const ensureCapacitorNotificationChannel = async (): Promise<void> => {
if (notificationChannelCreated || !isAndroid()) return;
@@ -375,7 +293,7 @@ const ensureCapacitorNotificationChannel = async (): Promise<void> => {
* Request notification permission across Electron, Tauri, Capacitor, and browser
*/
export const requestSystemNotificationPermission = async (): Promise<boolean> => {
if (isElectron() || (isTauri() && !isElectron())) {
if (isElectron()) {
if (!('Notification' in window)) return false;
const permission = await Notification.requestPermission();
return permission === 'granted';
@@ -423,8 +341,7 @@ export const getSystemNotificationPermissionState = async (): Promise<Permission
};
/**
* Send a notification using Tauri's notification plugin
* Falls back to browser Notification API if not in Tauri
* Send a notification on Electron or Capacitor, falling back to the browser Notification API
*/
export const sendNotification = async (options: {
title: string;
@@ -453,40 +370,6 @@ export const sendNotification = async (options: {
}
}
// Use Tauri plugin for actual Tauri builds (not Electron)
if (isTauri() && !isElectron()) {
try {
const {
sendNotification: tauriSendNotification,
isPermissionGranted,
requestPermission,
} = await import('@tauri-apps/plugin-notification');
let permissionGranted = await isPermissionGranted();
if (!permissionGranted) {
const permission = await requestPermission();
permissionGranted = permission === 'granted';
}
if (permissionGranted) {
// Ensure notification channel exists on Android
await ensureNotificationChannel();
await tauriSendNotification({
title,
body,
// Use the channel on Android
channelId: isAndroid() ? 'messages' : undefined,
// Store path in extra data for notification tap handling
extra: path ? { path } : undefined,
});
}
return;
} catch (err) {
console.warn('Tauri notification failed:', err);
}
}
if (isCapacitorNative()) {
try {
const { LocalNotifications } = await importCapacitorLocalNotifications();
@@ -563,25 +446,6 @@ export const readClipboardImage = async (): Promise<File | null> => {
}
}
// Use Tauri's invoke for actual Tauri builds on Linux
if (isTauri() && !isElectron() && isLinux()) {
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
const response = await fetch(dataUrl);
const blob = await response.blob();
if (blob.size < 32) return null;
return new File([blob], 'clipboard-image.png', { type: 'image/png' });
} catch (err) {
console.warn('Failed to read Tauri clipboard image:', err);
return null;
}
}
return null;
};