mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 14:56:20 +01:00
Fix album time not preserved on load
This commit is contained in:
parent
aada2e12e2
commit
002ede3392
3 changed files with 19 additions and 8 deletions
|
@ -17,6 +17,7 @@ import 'package:nc_photos/entity/file/data_source.dart';
|
||||||
import 'package:nc_photos/exception.dart';
|
import 'package:nc_photos/exception.dart';
|
||||||
import 'package:nc_photos/int_util.dart' as int_util;
|
import 'package:nc_photos/int_util.dart' as int_util;
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
|
import 'package:nc_photos/or_null.dart';
|
||||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||||
import 'package:nc_photos/use_case/get_file_binary.dart';
|
import 'package:nc_photos/use_case/get_file_binary.dart';
|
||||||
import 'package:nc_photos/use_case/ls.dart';
|
import 'package:nc_photos/use_case/ls.dart';
|
||||||
|
@ -98,11 +99,11 @@ class Album with EquatableMixin {
|
||||||
|
|
||||||
/// Return a copy with specified field modified
|
/// Return a copy with specified field modified
|
||||||
///
|
///
|
||||||
/// [lastUpdated] is handled differently where if null, the current time will
|
/// [lastUpdated] is handled differently where if not set, the current time
|
||||||
/// be used. In order to keep [lastUpdated], you must explicitly assign it
|
/// will be used. In order to keep [lastUpdated], you must explicitly assign
|
||||||
/// with value from this
|
/// it with value from this or a null value
|
||||||
Album copyWith({
|
Album copyWith({
|
||||||
DateTime lastUpdated,
|
OrNull<DateTime> lastUpdated,
|
||||||
String name,
|
String name,
|
||||||
AlbumProvider provider,
|
AlbumProvider provider,
|
||||||
AlbumCoverProvider coverProvider,
|
AlbumCoverProvider coverProvider,
|
||||||
|
@ -110,7 +111,8 @@ class Album with EquatableMixin {
|
||||||
File albumFile,
|
File albumFile,
|
||||||
}) {
|
}) {
|
||||||
return Album(
|
return Album(
|
||||||
lastUpdated: lastUpdated,
|
lastUpdated:
|
||||||
|
lastUpdated == null ? null : (lastUpdated.obj ?? this.lastUpdated),
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
provider: provider ?? this.provider,
|
provider: provider ?? this.provider,
|
||||||
coverProvider: coverProvider ?? this.coverProvider,
|
coverProvider: coverProvider ?? this.coverProvider,
|
||||||
|
@ -220,7 +222,10 @@ class AlbumRemoteDataSource implements AlbumDataSource {
|
||||||
upgraderV1: AlbumUpgraderV1(),
|
upgraderV1: AlbumUpgraderV1(),
|
||||||
upgraderV2: AlbumUpgraderV2(),
|
upgraderV2: AlbumUpgraderV2(),
|
||||||
upgraderV3: AlbumUpgraderV3(),
|
upgraderV3: AlbumUpgraderV3(),
|
||||||
).copyWith(albumFile: albumFile);
|
).copyWith(
|
||||||
|
lastUpdated: OrNull(null),
|
||||||
|
albumFile: albumFile,
|
||||||
|
);
|
||||||
} catch (e, stacktrace) {
|
} catch (e, stacktrace) {
|
||||||
dynamic d = data;
|
dynamic d = data;
|
||||||
try {
|
try {
|
||||||
|
@ -288,6 +293,7 @@ class AlbumAppDbDataSource implements AlbumDataSource {
|
||||||
return AlbumStaticProvider.of(e.album).items;
|
return AlbumStaticProvider.of(e.album).items;
|
||||||
}).reduce((value, element) => value + element);
|
}).reduce((value, element) => value + element);
|
||||||
return entries.first.album.copyWith(
|
return entries.first.album.copyWith(
|
||||||
|
lastUpdated: OrNull(null),
|
||||||
provider: AlbumStaticProvider(
|
provider: AlbumStaticProvider(
|
||||||
items: items,
|
items: items,
|
||||||
),
|
),
|
||||||
|
@ -423,6 +429,7 @@ Future<void> _cacheAlbum(
|
||||||
path,
|
path,
|
||||||
pair.item1,
|
pair.item1,
|
||||||
album.copyWith(
|
album.copyWith(
|
||||||
|
lastUpdated: OrNull(null),
|
||||||
provider: AlbumStaticProvider(items: pair.item2),
|
provider: AlbumStaticProvider(items: pair.item2),
|
||||||
))));
|
))));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
|
import 'package:nc_photos/or_null.dart';
|
||||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||||
import 'package:nc_photos/session_storage.dart';
|
import 'package:nc_photos/session_storage.dart';
|
||||||
import 'package:nc_photos/share_handler.dart';
|
import 'package:nc_photos/share_handler.dart';
|
||||||
|
@ -119,7 +120,8 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
// persist the changes
|
// persist the changes
|
||||||
_editFormKey.currentState.save();
|
_editFormKey.currentState.save();
|
||||||
final newAlbum = makeEdited(_editAlbum);
|
final newAlbum = makeEdited(_editAlbum);
|
||||||
if (newAlbum.copyWith(lastUpdated: _album.lastUpdated) != _album) {
|
if (newAlbum.copyWith(lastUpdated: OrNull(_album.lastUpdated)) !=
|
||||||
|
_album) {
|
||||||
_log.info("[doneEditMode] Album modified: $newAlbum");
|
_log.info("[doneEditMode] Album modified: $newAlbum");
|
||||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
|
import 'package:nc_photos/or_null.dart';
|
||||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||||
import 'package:nc_photos/share_handler.dart';
|
import 'package:nc_photos/share_handler.dart';
|
||||||
import 'package:nc_photos/snack_bar_manager.dart';
|
import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
|
@ -107,7 +108,8 @@ class _DynamicAlbumViewerState extends State<DynamicAlbumViewer>
|
||||||
// persist the changes
|
// persist the changes
|
||||||
_editFormKey.currentState.save();
|
_editFormKey.currentState.save();
|
||||||
final newAlbum = makeEdited(_editAlbum);
|
final newAlbum = makeEdited(_editAlbum);
|
||||||
if (newAlbum.copyWith(lastUpdated: _album.lastUpdated) != _album) {
|
if (newAlbum.copyWith(lastUpdated: OrNull(_album.lastUpdated)) !=
|
||||||
|
_album) {
|
||||||
_log.info("[doneEditMode] Album modified: $newAlbum");
|
_log.info("[doneEditMode] Album modified: $newAlbum");
|
||||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
Loading…
Reference in a new issue