Skip to content

fix(web): Show resulting date range when changing by offset#28103

Open
svsantos42 wants to merge 2 commits intoimmich-app:mainfrom
svsantos42:fix-date-change-offset-show-range
Open

fix(web): Show resulting date range when changing by offset#28103
svsantos42 wants to merge 2 commits intoimmich-app:mainfrom
svsantos42:fix-date-change-offset-show-range

Conversation

@svsantos42
Copy link
Copy Markdown

Description

When selecting multiple assets on the main timeline and clicking the menu to "Change Date", it brings up the date change dialog. If you select to "Change date by offset", it used to show the resulting date range that would be applied to the selected photos with the desired change settings. This stopped working after v2.2, so this change brings that functionality back, which is very helpful when trying to change the dates of many photos at once.

Fixes #23659

How Has This Been Tested?

This was tested by uploading photos to Immich and then selecting multiple and doing the change date by offset operation. It now shows the resulting date range and it matches the dates that get applied after clicking confirm. This was tested on photos with different types of dates. Ones that already had a timezone in the metadata and ones that don't (like screenshots) and both ways produce the expected result. It was also tested by doing multiple date change operations in a row without refreshing the page to make sure the changes take effect instantly on the page for future changes.

Screenshots (if appropriate)

SCR-20260426-ucsf

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

No LLM usage, used the Immich docs to get an environment set up and to run the test commands once finished.

@immich-push-o-matic
Copy link
Copy Markdown

immich-push-o-matic Bot commented Apr 27, 2026

Label error. Requires exactly 1 of: changelog:.*. Found: 🖥️web. A maintainer will add the required label.

Comment on lines +41 to +53
let assetDates = $derived(
assets
.map((asset) => DateTime.fromObject(asset.localDateTime, { zone: asset.localOffsetHours ? 'local' : 'UTC' }))
.sort((a, b) => a.toMillis() - b.toMillis()),
);

let firstDate = $derived.by(() => {
let base = assetDates.at(0);
let date = showRelative && base ? calcNewDate(base, selectedDuration, selectedOption?.value) : base;
return getFullDateFormat(date);
});

let lastDate = $derived.by(() => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why these three derivedes can't be const?
Also, sorting is technically less efficient than just searching the earliest and latest date in two iterations.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't thought about that, I changed it to just loop through the array once instead of sorting the array. And I added const where it can be used.

Comment on lines +71 to +75
let updatedAssets = getOwnedAssetsObjects(assets, authManager.user);
for (let asset of updatedAssets) {
asset.localOffsetHours = selectedOption.offsetMinutes / 60;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is entirely unrelated, is it not?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to update the timezone offset of the assets currently on the page. If you refresh the page after changing the dates, then it gets the latest information. But if you try changing the date again without refreshing the page, it still has the old timezone offset if it changed, so it would show the wrong date range.

Comment on lines +123 to +124
<Text size="small">{$t('first')}: {firstDate}</Text>
<Text size="small">{$t('last')}: {lastDate}</Text>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use a translation key that takes an argument. Not in every language is it actually "First: "

Copy link
Copy Markdown
Author

@svsantos42 svsantos42 Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you recommend here? I don't speak any other languages, so I'm not sure what would be better than first/last.

Comment on lines +310 to +313
export const getOwnedAssetsObjects = (assets: TimelineAsset[], user: UserResponseDto | null): TimelineAsset[] => {
return [...assets].filter((a) => user && a.ownerId === user.id);
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just inline it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like just use the filter in onSubmit instead of creating a function here? I figured it might be a useful function for future use in other places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date change by offset does not show the resulting date range anymore

2 participants