-
Notifications
You must be signed in to change notification settings - Fork 522
fix: Open Folder Button in Image Viewer Does Nothing (Fixes #959) #974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: Open Folder Button in Image Viewer Does Nothing (Fixes #959) #974
Conversation
|
|
📝 WalkthroughWalkthroughThe change adds Tauri-specific folder-open functionality to MediaView.tsx with runtime environment checks. It introduces guarded dynamic imports of the Tauri plugin-opener and includes error handling for missing or unavailable functions. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant MediaView
participant isTauriEnvironment
participant Tauri Plugin
User->>MediaView: Click open folder
MediaView->>isTauriEnvironment: Check environment
alt Not Tauri
isTauriEnvironment-->>MediaView: false
MediaView->>MediaView: Log warning & return
else Is Tauri
isTauriEnvironment-->>MediaView: true
MediaView->>Tauri Plugin: Dynamic import opener
Tauri Plugin-->>MediaView: Plugin loaded
alt revealItemInDir exists
MediaView->>Tauri Plugin: Call revealItemInDir(imagePath)
Tauri Plugin-->>User: Reveal item in directory
else Function missing
MediaView->>MediaView: Log warning
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src/components/Media/MediaView.tsx (1)
106-109: Remove duplicate error logging.Both
console.log(err)andconsole.error('Failed to open folder.')are present. Theconsole.log(err)is redundant since the error details are already captured. Keep only theconsole.errorwith the error object for better debugging context.🔎 Proposed fix
} catch (err) { - console.log(err); - console.error('Failed to open folder.'); + console.error('Failed to open folder:', err); }
🧹 Nitpick comments (2)
frontend/src/components/Media/MediaView.tsx (2)
3-3: Remove commented-out import.The commented import is no longer needed since the plugin is now dynamically imported. Consider removing it to keep the codebase clean.
🔎 Cleanup suggestion
-// import { revealItemInDir } from '@tauri-apps/plugin-opener';
100-105: Consider simplifying the function existence check.The dynamic import approach is correct for lazy-loading the Tauri plugin. However, the
typeof opener.revealItemInDir === 'function'check is unnecessary—revealItemInDiris a documented, stable API in v2.5.2 that is consistently exported and always available when the module imports successfully.🔎 Suggested simplification
const opener = await import('@tauri-apps/plugin-opener'); -if (typeof opener.revealItemInDir === 'function') { - await opener.revealItemInDir(currentImage.path); -} else { - console.warn('revealItemInDir function not found'); -} +await opener.revealItemInDir(currentImage.path);
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/Media/MediaView.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/components/Media/MediaView.tsx (1)
frontend/src/utils/tauriUtils.ts (1)
isTauriEnvironment(15-38)
🔇 Additional comments (2)
frontend/src/components/Media/MediaView.tsx (2)
24-24: LGTM!The import of
isTauriEnvironmentis appropriate for guarding Tauri-specific functionality.
95-98: LGTM!The environment check properly guards against calling Tauri-specific functionality in non-Tauri environments (e.g., web browser).
|
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.