Skip to content

refactor(mobile): Migrate durationInSeconds to durationInMilliseconds#26615

Open
LeLunZ wants to merge 5 commits intoimmich-app:mainfrom
LeLunZ:migrate-to-milliseconds
Open

refactor(mobile): Migrate durationInSeconds to durationInMilliseconds#26615
LeLunZ wants to merge 5 commits intoimmich-app:mainfrom
LeLunZ:migrate-to-milliseconds

Conversation

@LeLunZ
Copy link
Collaborator

@LeLunZ LeLunZ commented Mar 1, 2026

The last refinement for showing animated images. Migrating durationInSeconds to durationInMilliseconds.
This is needed so all remote animated images show as actual animated images.

The current problem is that if an animated image is shorter than a second, then the duration will be set to 0, and thus all remote assets will just show as still image.

I hope I didn't touch any old code (old ISAR entities).

Regarding migration of current values: The db migration just multiplies the current value with 1000 which isn't optimal but:

  • it more or less has the same state as previously (as previously the milliseconds where omitted, so it doesn't really make a difference)
  • and next time the full local sync runs _assetsEqual will notice the change in milliseconds and updates the object.
  • The only "issue" is that images that currently have durationInSeconds 0 (but actually have a few milliseconds), will only be detected on the next full sync (whenever that is). But as this also was an issue before...I don't think that we need a migration for that? So I think this should be fine.
  • Or do you prefer if I add another dart side migration like _populateLocalAssetPlaybackStyle again?

@LeLunZ LeLunZ changed the title refactor(mobile): Migrate duration in seconds to milliseconds refactor(mobile): Migrate durationInSeconds to durationInMilliseconds Mar 1, 2026
@LeLunZ LeLunZ force-pushed the migrate-to-milliseconds branch from 7f5adde to 9f09fa8 Compare March 1, 2026 20:21
@LeLunZ LeLunZ marked this pull request as ready for review March 1, 2026 20:40
@LeLunZ LeLunZ requested a review from shenlong-tanwen as a code owner March 1, 2026 20:40
Copilot AI review requested due to automatic review settings March 1, 2026 20:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the asset duration field from durationInSeconds (integer, seconds precision) to durationInMilliseconds (integer, milliseconds precision) across the entire mobile stack. This fixes a bug where animated images shorter than one second would have their duration truncated to 0 and be displayed as still images.

Changes:

  • Renames durationInSecondsdurationInMilliseconds across all domain models, DB entities, platform pigeon APIs (Dart/Swift/Kotlin), and SQL queries.
  • Adds a Drift DB migration (v21 → v22) that renames the column and multiplies existing values by 1000.
  • Extends toDuration() to parse fractional seconds (e.g., "0:00:00.500000") in addition to plain HH:MM:SS strings.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
mobile/lib/domain/models/asset/base_asset.model.dart Core model field rename; playbackStyle and duration getters updated
mobile/lib/infrastructure/utils/asset.mixin.dart Drift table mixin field renamed
mobile/lib/infrastructure/repositories/db.repository.dart Schema version bumped to 22; migration from v21 added
mobile/lib/infrastructure/repositories/db.repository.steps.dart Generated migration steps for Schema22
mobile/lib/extensions/string_extensions.dart toDuration() updated to handle fractional seconds
mobile/ios/Runner/Sync/PHAssetExtensions.swift iOS: duration now passed as milliseconds (* 1000)
mobile/android/app/src/main/kotlin/app/alextran/immich/sync/MessagesImplBase.kt Android: removed /1000 division (MediaStore already provides ms)
mobile/pigeon/native_sync_api.dart / Messages.g.* Platform message field rename in Dart/Swift/Kotlin
All entity/drift files Auto-generated code updated to reflect new column name
All test files Test fixtures and stubs updated

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LeLunZ LeLunZ force-pushed the migrate-to-milliseconds branch from 5ec11ee to 6e8b0eb Compare March 4, 2026 19:52
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.

2 participants