Skip to content

Commit 97fa495

Browse files
committed
fix: VC guard on filmstripActivePath, pickPrimary default case, cleanup
Issues found during code review: - filmstripActivePath was missing the is_virtual_copy guard that variantOptions already had. A VC of a grouped file would highlight the group primary in the filmstrip instead of itself. - pickPrimary switch had no default case. A corrupt settings file sending an unknown preference string would return undefined. - Use Set for extension dedup in groupBadgeInfo (was indexOf loop). - Add skip_serializing to deprecated group_associated_files so it stops being written back to the settings file. - Remove stale comment.
1 parent a9e7a81 commit 97fa495

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

src-tauri/src/file_management.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ pub struct AppSettings {
399399
pub active_waveform_channel: Option<String>,
400400
/// Deprecated: grouping is now driven by the rawStatus filter.
401401
/// Kept for backward-compatible deserialization of existing settings.
402-
#[serde(default)]
402+
#[serde(default, skip_serializing)]
403403
pub group_associated_files: Option<bool>,
404404
#[serde(default)]
405405
pub group_preferred_type: Option<String>,

src/App.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,12 @@ function App() {
10501050
return buildImageGroups(imageList, groupPreferredType);
10511051
}, [imageList, isGroupingActive, groupPreferredType]);
10521052

1053-
// Map from group_id to variant count, for rendering badges on thumbnails
10541053
// Badge info for grouped thumbnails: count + label like "RAF+JPG"
10551054
const groupBadgeInfo: Record<string, { count: number; label: string }> = useMemo(() => {
10561055
if (!groupingResult) return {};
10571056
const info: Record<string, { count: number; label: string }> = {};
10581057
for (const [groupId, group] of groupingResult.groups) {
1059-
const extensions = group.variants
1060-
.map((v) => getVariantLabel(v.path))
1061-
.filter((ext, i, arr) => arr.indexOf(ext) === i); // dedupe
1058+
const extensions = [...new Set(group.variants.map((v) => getVariantLabel(v.path)))];
10621059
info[groupId] = {
10631060
count: group.variants.length,
10641061
label: extensions.join('+'),
@@ -1087,7 +1084,7 @@ function App() {
10871084
if (!selectedImage) return null;
10881085
if (!groupingResult) return selectedImage.path;
10891086
const imageFile = imageList.find((img) => img.path === selectedImage.path);
1090-
if (!imageFile?.group_id) return selectedImage.path;
1087+
if (!imageFile?.group_id || imageFile.is_virtual_copy) return selectedImage.path;
10911088
const group = groupingResult.groups.get(imageFile.group_id);
10921089
return group?.primary.path ?? selectedImage.path;
10931090
}, [selectedImage?.path, groupingResult, imageList]);

src/utils/imageGrouping.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ function pickPrimary(files: ImageFile[], preference: GroupPreference): ImageFile
7777
return raw ?? nonRaw ?? files[0];
7878
case 'jpeg':
7979
return nonRaw ?? raw ?? files[0];
80+
default:
81+
return files[0];
8082
}
8183
}
8284

0 commit comments

Comments
 (0)