Skip to content

Commit

Permalink
code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Dec 11, 2023
1 parent 01a86bd commit fee53a0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
12 changes: 6 additions & 6 deletions starsky/starsky/clientapp/src/contexts/archive-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ function updateArchiveReducerTagsDescriptionTitleSet(
function updateArchiveReducerHelper(
action: {
type: "update";
tags?: string | undefined;
colorclass?: number | undefined;
description?: string | undefined;
title?: string | undefined;
append?: boolean | undefined;
tags?: string;
colorclass?: number;
description?: string;
title?: string;
append?: boolean;
select: string[];
fileHash?: string | undefined;
fileHash?: string;
},
state: IArchiveProps
) {
Expand Down
38 changes: 29 additions & 9 deletions starsky/starsky/clientapp/src/contexts/detailview-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ function updateReducer(
action: {
type: "update";
filePath: string;
tags?: string | undefined;
colorclass?: number | undefined;
description?: string | undefined;
title?: string | undefined;
fileHash?: string | undefined;
locationState?: string | undefined;
tags?: string;
colorclass?: number;
description?: string;
title?: string;
fileHash?: string;
status?: IExifStatus;
orientation?: Orientation;
lastEdited?: string;
Expand All @@ -83,6 +82,7 @@ function updateReducer(
locationCountry?: string;
locationCountryCode?: string;
locationCity?: string;
locationState?: string;
},
state: IDetailView
) {
Expand Down Expand Up @@ -122,6 +122,29 @@ function updateReducer(
if (orientation) state.fileIndexItem.orientation = orientation;
if (lastEdited) state.fileIndexItem.lastEdited = lastEdited;
if (dateTime) state.fileIndexItem.dateTime = dateTime;
updateReducerSetLocationTypes(
state,
latitude,
longitude,
locationCity,
locationState,
locationCountry,
locationCountryCode
);

// Need to update otherwise other events are not triggered
return updateCache({ ...state, lastUpdated: new Date() });
}

function updateReducerSetLocationTypes(
state: IDetailView,
latitude?: number,
longitude?: number,
locationCity?: string,
locationState?: string,
locationCountry?: string,
locationCountryCode?: string
) {
if (latitude) state.fileIndexItem.latitude = latitude;
if (longitude) state.fileIndexItem.longitude = longitude;
if (locationCity) state.fileIndexItem.locationCity = locationCity;
Expand All @@ -132,9 +155,6 @@ function updateReducer(
state.fileIndexItem.locationCountryCode = locationCountryCode;
}
if (locationState) state.fileIndexItem.locationState = locationState;

// Need to update otherwise other events are not triggered
return updateCache({ ...state, lastUpdated: new Date() });
}

export function detailviewReducer(
Expand Down

0 comments on commit fee53a0

Please sign in to comment.