Compare commits
2
Commits
b158648fc4
...
d6fe94ff48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6fe94ff48 | ||
|
|
0f60822cec |
Generated
-70
@@ -20,13 +20,6 @@
|
||||
"@tanstack/react-query-devtools": "5.101.2",
|
||||
"@tanstack/react-virtual": "3.14.5",
|
||||
"@tauri-apps/api": "2.11.1",
|
||||
"@tauri-apps/plugin-dialog": "2.7.1",
|
||||
"@tauri-apps/plugin-fs": "2.5.1",
|
||||
"@tauri-apps/plugin-http": "2.5.9",
|
||||
"@tauri-apps/plugin-notification": "2.3.3",
|
||||
"@tauri-apps/plugin-opener": "2",
|
||||
"@tauri-apps/plugin-process": "2.3.1",
|
||||
"@tauri-apps/plugin-updater": "2.10.1",
|
||||
"@types/pako": "2.0.4",
|
||||
"@vanilla-extract/css": "1.21.1",
|
||||
"@vanilla-extract/recipes": "0.5.7",
|
||||
@@ -4080,69 +4073,6 @@
|
||||
"url": "https://opencollective.com/tauri"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-dialog": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-dialog/-/plugin-dialog-2.7.1.tgz",
|
||||
"integrity": "sha512-OK1UBXYt+ojcmxMktzzuyonYIFta8CmAASpX+CA+DTGK24KlHjhYI6x2iOJ/TjZF4N7/ACK1oFmEOjIY9IhzOQ==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-fs": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-fs/-/plugin-fs-2.5.1.tgz",
|
||||
"integrity": "sha512-9Lz+Jopp6QyeEWhlpkMx4R/+P9HgR+AVAI4vOZhlT8Xaymtz8iVI/Ov984/XTqgJz/5gz5NretqPB/XEMS3NhQ==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-http": {
|
||||
"version": "2.5.9",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-http/-/plugin-http-2.5.9.tgz",
|
||||
"integrity": "sha512-lCiY0+vs4HvIUSvZrBs8TC3TiCB0MOPRmiUjTq4prW7SlcJE2jdLeT6KBsJrT9Tlplufl7W1pY6SFAO3gCWxDA==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-notification": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-notification/-/plugin-notification-2.3.3.tgz",
|
||||
"integrity": "sha512-Zw+ZH18RJb41G4NrfHgIuofJiymusqN+q8fGUIIV7vyCH+5sSn5coqRv/MWB9qETsUs97vmU045q7OyseCV3Qg==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-opener": {
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-opener/-/plugin-opener-2.5.3.tgz",
|
||||
"integrity": "sha512-CCcUltXMOfUEArbf3db3kCE7Ggy1ExBEBl51Ko2ODJ6GDYHRp1nSNlQm5uNCFY5k7/ufaK5Ib3Du/Zir19IYQQ==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-process": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-process/-/plugin-process-2.3.1.tgz",
|
||||
"integrity": "sha512-nCa4fGVaDL/B9ai03VyPOjfAHRHSBz5v6F/ObsB73r/dA3MHHhZtldaDMIc0V/pnUw9ehzr2iEG+XkSEyC0JJA==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tauri-apps/plugin-updater": {
|
||||
"version": "2.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@tauri-apps/plugin-updater/-/plugin-updater-2.10.1.tgz",
|
||||
"integrity": "sha512-NFYMg+tWOZPJdzE/PpFj2qfqwAWwNS3kXrb1tm1gnBJ9mYzZ4WDRrwy8udzWoAnfGCHLuePNLY1WVCNHnh3eRA==",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.10.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@trickfilm400/rollup-plugin-off-main-thread": {
|
||||
"version": "3.0.0-pre1",
|
||||
"resolved": "https://registry.npmjs.org/@trickfilm400/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-3.0.0-pre1.tgz",
|
||||
|
||||
@@ -31,13 +31,6 @@
|
||||
"@tanstack/react-query-devtools": "5.101.2",
|
||||
"@tanstack/react-virtual": "3.14.5",
|
||||
"@tauri-apps/api": "2.11.1",
|
||||
"@tauri-apps/plugin-dialog": "2.7.1",
|
||||
"@tauri-apps/plugin-fs": "2.5.1",
|
||||
"@tauri-apps/plugin-http": "2.5.9",
|
||||
"@tauri-apps/plugin-notification": "2.3.3",
|
||||
"@tauri-apps/plugin-opener": "2",
|
||||
"@tauri-apps/plugin-process": "2.3.1",
|
||||
"@tauri-apps/plugin-updater": "2.10.1",
|
||||
"@types/pako": "2.0.4",
|
||||
"@vanilla-extract/css": "1.21.1",
|
||||
"@vanilla-extract/recipes": "0.5.7",
|
||||
|
||||
@@ -30,7 +30,7 @@ AuthenticatedMedia.displayName = 'AuthenticatedMedia';
|
||||
* A simpler authenticated img component for use in places like custom HTML parsers.
|
||||
* This component handles its own authentication state.
|
||||
*/
|
||||
export interface AuthenticatedImgProps extends ImgHTMLAttributes<HTMLImageElement> {}
|
||||
export type AuthenticatedImgProps = ImgHTMLAttributes<HTMLImageElement>;
|
||||
|
||||
export const AuthenticatedImg = forwardRef<HTMLImageElement, AuthenticatedImgProps>(
|
||||
({ src, ...props }, ref) => {
|
||||
|
||||
@@ -108,7 +108,6 @@ export const TikTokEmbedContainer = style([
|
||||
{
|
||||
width: '100%',
|
||||
height: toRem(550),
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
backgroundColor: '#000',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import React, { createContext, useContext, useMemo } from 'react';
|
||||
import { RectCords } from 'folds';
|
||||
|
||||
type ForumMessageMenuContextValue = {
|
||||
@@ -14,10 +14,10 @@ export function ForumMessageMenuProvider({
|
||||
openMenu: (anchor: RectCords) => void;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const value = useMemo(() => ({ openMenu }), [openMenu]);
|
||||
|
||||
return (
|
||||
<ForumMessageMenuContext.Provider value={{ openMenu }}>
|
||||
{children}
|
||||
</ForumMessageMenuContext.Provider>
|
||||
<ForumMessageMenuContext.Provider value={value}>{children}</ForumMessageMenuContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ const CROWN: SvgNode[] = [
|
||||
];
|
||||
|
||||
function lucideIcon(nodes: SvgNode): IconSrc {
|
||||
return function () {
|
||||
return function Icon() {
|
||||
return (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
||||
@@ -111,6 +111,8 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
[mx],
|
||||
);
|
||||
|
||||
const closeProfileField = useCallback(() => setProfileFieldKey(undefined), []);
|
||||
|
||||
if (accountDataType !== undefined) {
|
||||
return (
|
||||
<AccountDataEditor
|
||||
@@ -122,8 +124,6 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const closeProfileField = useCallback(() => setProfileFieldKey(undefined), []);
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader outlined={false}>
|
||||
|
||||
@@ -92,13 +92,15 @@ export function useTypingVerbs(userIds: string[]): Record<string, string | undef
|
||||
let cancelled = false;
|
||||
const unsubscribe = registerProfileCacheListener(() => setTick((tick) => tick + 1));
|
||||
|
||||
// setProfileCache does not notify listeners, so a fresh fetch has to re-render here
|
||||
const rerender = () => {
|
||||
if (!cancelled) setTick((tick) => tick + 1);
|
||||
};
|
||||
|
||||
for (const userId of key.split(',')) {
|
||||
if (getCachedProfileFields(userId)) continue;
|
||||
// setProfileCache does not notify listeners, so a fresh fetch has to re-render here
|
||||
getProfileFields(mx, userId)
|
||||
.then(() => {
|
||||
if (!cancelled) setTick((tick) => tick + 1);
|
||||
})
|
||||
.then(rerender)
|
||||
.catch(() => undefined);
|
||||
}
|
||||
|
||||
|
||||
@@ -215,10 +215,11 @@ export function extractMetadataFromImage(imageData: ArrayBuffer | Uint8Array): I
|
||||
console.log('[extractMetadataFromImage] Detected format:', format);
|
||||
|
||||
switch (format) {
|
||||
case 'png':
|
||||
case 'png': {
|
||||
const pngMetadata = extractMetadataFromPNG(imageData);
|
||||
console.log('[extractMetadataFromImage] PNG metadata:', pngMetadata);
|
||||
return pngMetadata;
|
||||
}
|
||||
// For other formats, extract color only for now
|
||||
case 'webp':
|
||||
case 'jpeg':
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { registerMediaSaver } from './saveMedia';
|
||||
import { isElectron, isTauri } from './tauri';
|
||||
import { isElectron } from './tauri';
|
||||
|
||||
type ElectronSaveResult = {
|
||||
success?: boolean;
|
||||
@@ -21,49 +21,6 @@ async function blobToUint8Array(blob: Blob): Promise<Uint8Array> {
|
||||
return new Uint8Array(buffer);
|
||||
}
|
||||
|
||||
function guessFilters(
|
||||
filename: string,
|
||||
mimeType?: string,
|
||||
): Array<{ name: string; extensions: string[] }> {
|
||||
const ext = filename.includes('.') ? filename.split('.').pop()!.toLowerCase() : '';
|
||||
const mime = (mimeType || '').toLowerCase();
|
||||
|
||||
if (
|
||||
mime.startsWith('image/') ||
|
||||
['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)
|
||||
) {
|
||||
return [
|
||||
{ name: 'Images', extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'] },
|
||||
{ name: 'All Files', extensions: ['*'] },
|
||||
];
|
||||
}
|
||||
if (mime.startsWith('video/') || ['mp4', 'webm', 'mkv', 'mov'].includes(ext)) {
|
||||
return [
|
||||
{ name: 'Videos', extensions: ['mp4', 'webm', 'mkv', 'mov'] },
|
||||
{ name: 'All Files', extensions: ['*'] },
|
||||
];
|
||||
}
|
||||
if (mime.startsWith('audio/') || ['mp3', 'ogg', 'wav', 'm4a', 'flac'].includes(ext)) {
|
||||
return [
|
||||
{ name: 'Audio', extensions: ['mp3', 'ogg', 'wav', 'm4a', 'flac'] },
|
||||
{ name: 'All Files', extensions: ['*'] },
|
||||
];
|
||||
}
|
||||
if (mime === 'application/pdf' || ext === 'pdf') {
|
||||
return [
|
||||
{ name: 'PDF', extensions: ['pdf'] },
|
||||
{ name: 'All Files', extensions: ['*'] },
|
||||
];
|
||||
}
|
||||
if (ext) {
|
||||
return [
|
||||
{ name: ext.toUpperCase(), extensions: [ext] },
|
||||
{ name: 'All Files', extensions: ['*'] },
|
||||
];
|
||||
}
|
||||
return [{ name: 'All Files', extensions: ['*'] }];
|
||||
}
|
||||
|
||||
async function saveWithElectron(blob: Blob, filename: string): Promise<void> {
|
||||
const media = (window.electron as { media?: ElectronMediaApi } | undefined)?.media;
|
||||
if (!media?.saveFile) {
|
||||
@@ -82,25 +39,6 @@ async function saveWithElectron(blob: Blob, filename: string): Promise<void> {
|
||||
throw new Error(result.error || 'Failed to save file');
|
||||
}
|
||||
}
|
||||
|
||||
async function saveWithTauri(blob: Blob, filename: string): Promise<void> {
|
||||
const { save } = await import('@tauri-apps/plugin-dialog');
|
||||
const { writeFile } = await import('@tauri-apps/plugin-fs');
|
||||
|
||||
const path = await save({
|
||||
defaultPath: filename,
|
||||
filters: guessFilters(filename, blob.type),
|
||||
});
|
||||
if (!path) return;
|
||||
|
||||
const data = await blobToUint8Array(blob);
|
||||
await writeFile(path, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire Electron / Tauri native save dialogs into core saveMedia helpers.
|
||||
* Call once at desktop app startup. No-ops in plain browser.
|
||||
*/
|
||||
export function registerDesktopMediaSaver(): void {
|
||||
if (isElectron()) {
|
||||
registerMediaSaver(async (blob, filename) => {
|
||||
@@ -108,10 +46,4 @@ export function registerDesktopMediaSaver(): void {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTauri()) {
|
||||
registerMediaSaver(async (blob, filename) => {
|
||||
await saveWithTauri(blob, filename);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+4
-140
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Tauri shell open utility, only imported in Tauri builds
|
||||
*/
|
||||
|
||||
export async function openWithTauriShell(url: string): Promise<void> {
|
||||
// @ts-ignore
|
||||
const { open } = await import(/* @vite-ignore */ '@tauri-apps/plugin-shell');
|
||||
await open(url);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { MatrixClient } from 'matrix-js-sdk';
|
||||
import { fetch as tauriFetch } from '@tauri-apps/plugin-http';
|
||||
import { AccountDataEvent } from '../../types/matrix/accountData';
|
||||
import { ImageUsage, PackContent, PackImages } from '../plugins/custom-emoji/types';
|
||||
import { getAccountData } from './room';
|
||||
@@ -137,7 +136,7 @@ async function getFilePath(botToken: string, fileId: string): Promise<string> {
|
||||
* @returns File blob
|
||||
*/
|
||||
async function downloadFile(botToken: string, filePath: string): Promise<Blob> {
|
||||
const response = await tauriFetch(`${TELEGRAM_FILE_API}${botToken}/${filePath}`);
|
||||
const response = await fetch(`${TELEGRAM_FILE_API}${botToken}/${filePath}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download file: ${response.statusText}`);
|
||||
|
||||
+1
-57
@@ -15,7 +15,7 @@ import './index.css';
|
||||
|
||||
import { trimTrailingSlash } from './app/utils/common';
|
||||
import App from './app/pages/App';
|
||||
import { applySafeAreaInsets, isTauri } from './app/utils/tauri';
|
||||
import { applySafeAreaInsets } from './app/utils/tauri';
|
||||
import { enableViewTransitionsForNavigation } from './app/utils/viewTransitions';
|
||||
import { registerDesktopMediaSaver } from './app/utils/registerDesktopMediaSaver';
|
||||
|
||||
@@ -60,57 +60,6 @@ if ('serviceWorker' in navigator) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're running in Electron (not Tauri)
|
||||
* Electron exposes window.electron in preload.js
|
||||
*/
|
||||
const isElectron = (): boolean => 'electron' in window;
|
||||
|
||||
/**
|
||||
* Check for app updates using Tauri updater
|
||||
* Prompts user if update is available and handles download/install
|
||||
* Note: Electron has its own auto-updater in main.js, so skip for Electron
|
||||
*/
|
||||
async function checkForUpdates() {
|
||||
// Skip if in Electron - Electron has its own auto-updater
|
||||
if (isElectron()) {
|
||||
console.log('Update check skipped - Electron handles updates natively');
|
||||
return;
|
||||
}
|
||||
|
||||
// Only run in Tauri context (not Electron)
|
||||
if (!isTauri() || isElectron()) {
|
||||
console.log('Update check skipped - not running in Tauri');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Checking for updates...');
|
||||
try {
|
||||
const { check } = await import('@tauri-apps/plugin-updater');
|
||||
const { ask } = await import('@tauri-apps/plugin-dialog');
|
||||
const { relaunch } = await import('@tauri-apps/plugin-process');
|
||||
|
||||
const update = await check();
|
||||
console.log('Update check result:', update);
|
||||
if (update) {
|
||||
console.log(`Update available: ${update.version}`);
|
||||
const shouldUpdate = await ask(
|
||||
`A new version (${update.version}) is available. Would you like to update now?`,
|
||||
{ title: 'Update Available', kind: 'info' },
|
||||
);
|
||||
if (shouldUpdate) {
|
||||
console.log('User chose to update, downloading...');
|
||||
await update.downloadAndInstall();
|
||||
await relaunch();
|
||||
}
|
||||
} else {
|
||||
console.log('App is up to date');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to check for updates:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const mountApp = () => {
|
||||
const rootContainer = document.getElementById('root');
|
||||
|
||||
@@ -124,8 +73,3 @@ const mountApp = () => {
|
||||
};
|
||||
|
||||
mountApp();
|
||||
|
||||
// Check for updates after app loads (with delay to not block startup)
|
||||
setTimeout(() => {
|
||||
checkForUpdates();
|
||||
}, 3000);
|
||||
|
||||
Reference in New Issue
Block a user