Fix new provider being created instead of modified

This commit is contained in:
Ming Ming 2021-09-25 13:45:02 +08:00
parent 99b3e9f7fa
commit a15f7a0db6
5 changed files with 12 additions and 10 deletions

View file

@ -297,7 +297,7 @@ class AlbumAppDbDataSource implements AlbumDataSource {
}).reduce((value, element) => value + element);
return entries.first.album.copyWith(
lastUpdated: OrNull(null),
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(entries.first.album).copyWith(
items: items,
),
);
@ -433,7 +433,9 @@ Future<void> _cacheAlbum(
pair.item1,
album.copyWith(
lastUpdated: OrNull(null),
provider: AlbumStaticProvider(items: pair.item2),
provider: AlbumStaticProvider.of(album).copyWith(
items: pair.item2,
),
))));
} else {
entries.add(AppDbAlbumEntry(path, 0, album));

View file

@ -12,7 +12,7 @@ class AddToAlbum {
UpdateAlbum(albumRepo)(
account,
album.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(album).copyWith(
items: makeDistinctAlbumItems([
...items,
...AlbumStaticProvider.of(album).items,

View file

@ -96,7 +96,7 @@ class _CleanUpAlbums {
await UpdateAlbum(albumRepo)(
account,
a.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(a).copyWith(
items: newItems,
),
));

View file

@ -325,7 +325,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
final albumRepo = AlbumRepo(AlbumCachedDataSource());
final newAlbum = _album!.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(_album!).copyWith(
items: newItems,
),
);
@ -449,7 +449,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
_editAlbum = _editAlbum!.copyWith(
sortProvider: const AlbumNullSortProvider(),
// save the current order
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(_editAlbum!).copyWith(
items: _sortedItems,
),
);
@ -467,7 +467,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
return;
}
_editAlbum = _editAlbum!.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(_editAlbum!).copyWith(
items: [
AlbumLabelItem(text: value),
..._sortedItems,
@ -492,7 +492,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
}
_sortedItems[index] = AlbumLabelItem(text: value);
_editAlbum = _editAlbum!.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(_editAlbum!).copyWith(
items: _sortedItems,
),
);
@ -624,7 +624,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
return e[0];
}).toList();
final propagateAlbum = album.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(album).copyWith(
items: propagateItems,
),
);

View file

@ -308,7 +308,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
await UpdateAlbum(albumRepo)(
widget.account,
widget.album!.copyWith(
provider: AlbumStaticProvider(
provider: AlbumStaticProvider.of(widget.album!).copyWith(
items: newItems,
),
));