Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,17 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin() {
numericId, rawMediaType, specialFormatColumn, xmpColumn, c
)

val isFlipped = orientation == 90 || orientation == 270
val asset = PlatformAsset(
id,
name,
assetType,
createdAt,
modifiedAt,
width,
height,
if (isFlipped) height else width,
if (isFlipped) width else height,
duration,
orientation.toLong(),
0L,
isFavorite,
playbackStyle = playbackStyle,
)
Expand Down
18 changes: 17 additions & 1 deletion mobile/lib/utils/migration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import 'package:isar/isar.dart';
// ignore: import_rule_photo_manager
import 'package:photo_manager/photo_manager.dart';

const int targetVersion = 23;
const int targetVersion = 24;

Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
final hasVersion = Store.tryGet(StoreKey.version) != null;
Expand Down Expand Up @@ -105,6 +105,10 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
await _populateLocalAssetPlaybackStyle(drift);
}

if (version < 24 && Store.isBetaTimelineEnabled) {
await _applyLocalAssetOrientation(drift);
}

if (version < 22 && !Store.isBetaTimelineEnabled) {
await Store.put(StoreKey.needBetaMigration, true);
}
Expand Down Expand Up @@ -436,6 +440,18 @@ Future<void> _populateLocalAssetPlaybackStyle(Drift db) async {
}
}

Future<void> _applyLocalAssetOrientation(Drift db) {
final query = db.localAssetEntity.update()
..where((filter) => (filter.orientation.equals(90) | (filter.orientation.equals(270))));
return query.write(
LocalAssetEntityCompanion.custom(
width: db.localAssetEntity.height,
height: db.localAssetEntity.width,
orientation: const Variable(0),
),
);
}

AssetPlaybackStyle _toPlaybackStyle(PlatformAssetPlaybackStyle style) => switch (style) {
PlatformAssetPlaybackStyle.unknown => AssetPlaybackStyle.unknown,
PlatformAssetPlaybackStyle.image => AssetPlaybackStyle.image,
Expand Down
Loading