From f4ba012c373da24de8372e0710f1c57059d7ca2e Mon Sep 17 00:00:00 2001 From: Akash Shrivastav Date: Mon, 15 Dec 2025 00:27:04 +0530 Subject: [PATCH] fix: enable Open Original File using plugin-opener (closes #688) --- docs/backend/backend_python/openapi.json | 10 ++++-- frontend/src-tauri/2 | 12 +++++++ frontend/src-tauri/Cargo.toml | 2 +- frontend/src-tauri/capabilities/migrated.json | 26 ++++++++++++++-- .../src/components/Media/MediaInfoPanel.tsx | 31 ++++++++++--------- 5 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 frontend/src-tauri/2 diff --git a/docs/backend/backend_python/openapi.json b/docs/backend/backend_python/openapi.json index 44eb908b1..a29e7c4f1 100644 --- a/docs/backend/backend_python/openapi.json +++ b/docs/backend/backend_python/openapi.json @@ -1117,9 +1117,14 @@ "in": "query", "required": false, "schema": { - "$ref": "#/components/schemas/InputType", + "allOf": [ + { + "$ref": "#/components/schemas/InputType" + } + ], "description": "Choose input type: 'path' or 'base64'", - "default": "path" + "default": "path", + "title": "Input Type" }, "description": "Choose input type: 'path' or 'base64'" } @@ -2199,7 +2204,6 @@ "metadata": { "anyOf": [ { - "additionalProperties": true, "type": "object" }, { diff --git a/frontend/src-tauri/2 b/frontend/src-tauri/2 new file mode 100644 index 000000000..3fdaac164 --- /dev/null +++ b/frontend/src-tauri/2 @@ -0,0 +1,12 @@ + +up to date, audited 901 packages in 3s + +165 packages are looking for funding + run `npm fund` for details + +1 moderate severity vulnerability + +To address all issues, run: + npm audit fix + +Run `npm audit` for details. diff --git a/frontend/src-tauri/Cargo.toml b/frontend/src-tauri/Cargo.toml index 27a402134..ef64150a7 100644 --- a/frontend/src-tauri/Cargo.toml +++ b/frontend/src-tauri/Cargo.toml @@ -34,7 +34,7 @@ tauri-plugin-dialog = "2.4.2" tauri-plugin-process = "2.3.1" tauri-plugin-store = "2.4.1" tauri-plugin-updater = "2.9.0" -tauri-plugin-opener = "2.5.2" +tauri-plugin-opener = "2" [features] # This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!! diff --git a/frontend/src-tauri/capabilities/migrated.json b/frontend/src-tauri/capabilities/migrated.json index 451192eb2..84fbc9146 100644 --- a/frontend/src-tauri/capabilities/migrated.json +++ b/frontend/src-tauri/capabilities/migrated.json @@ -136,6 +136,28 @@ "fs:default", "dialog:default", "store:default", - "opener:allow-reveal-item-in-dir" + "opener:allow-reveal-item-in-dir", + "opener:allow-open-path", + "opener:allow-open-url", + "opener:allow-default-urls", + { + "identifier": "opener:allow-open-path", + "allow": [ + { + "path": "**" + } + ] + }, + { + "identifier": "opener:allow-open-url", + "allow": [ + { + "url": "https://*" + }, + { + "url": "http://*" + } + ] + } ] -} +} \ No newline at end of file diff --git a/frontend/src/components/Media/MediaInfoPanel.tsx b/frontend/src/components/Media/MediaInfoPanel.tsx index c192aef4b..3f199a4c2 100644 --- a/frontend/src/components/Media/MediaInfoPanel.tsx +++ b/frontend/src/components/Media/MediaInfoPanel.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { open } from '@tauri-apps/plugin-shell'; +import { openPath, openUrl } from '@tauri-apps/plugin-opener'; import { X, ImageIcon as ImageLucide, @@ -26,6 +26,18 @@ export const MediaInfoPanel: React.FC = ({ currentIndex, totalImages, }) => { + const handleLocationClick = async () => { + if (currentImage?.metadata?.latitude && currentImage?.metadata?.longitude) { + const { latitude, longitude } = currentImage.metadata; + const url = `https://maps.google.com/?q=${latitude},${longitude}`; + try { + await openUrl(url); + } catch (error) { + console.error('Failed to open map URL:', error); + } + } + }; + const getFormattedDate = () => { if (currentImage?.metadata?.date_created) { return new Date(currentImage.metadata.date_created).toLocaleDateString( @@ -46,18 +58,6 @@ export const MediaInfoPanel: React.FC = ({ return currentImage.path?.split(/[/\\]/).pop() || 'Image'; }; - const handleLocationClick = async () => { - if (currentImage?.metadata?.latitude && currentImage?.metadata?.longitude) { - const { latitude, longitude } = currentImage.metadata; - const url = `https://maps.google.com/?q=${latitude},${longitude}`; - try { - await open(url); - } catch (error) { - console.error('Failed to open map URL:', error); - } - } - }; - if (!show) return null; return ( @@ -163,7 +163,7 @@ export const MediaInfoPanel: React.FC = ({ onClick={async () => { if (currentImage?.path) { try { - await open(currentImage.path); + await openPath(currentImage.path); } catch (error) { console.error('Failed to open file:', error); } @@ -171,9 +171,10 @@ export const MediaInfoPanel: React.FC = ({ }} > Open Original File + ); -}; +}; \ No newline at end of file