mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +02:00
fix(mobile) add and delete asset in album doesn' (#1474)
t update count in list
This commit is contained in:
parent
dfbc831525
commit
91114e5aa0
@ -6,10 +6,10 @@ import 'package:immich_mobile/shared/models/asset.dart';
|
|||||||
import 'package:openapi/api.dart';
|
import 'package:openapi/api.dart';
|
||||||
|
|
||||||
class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
||||||
SharedAlbumNotifier(this._sharedAlbumService, this._sharedAlbumCacheService)
|
SharedAlbumNotifier(this._albumService, this._sharedAlbumCacheService)
|
||||||
: super([]);
|
: super([]);
|
||||||
|
|
||||||
final AlbumService _sharedAlbumService;
|
final AlbumService _albumService;
|
||||||
final SharedAlbumCacheService _sharedAlbumCacheService;
|
final SharedAlbumCacheService _sharedAlbumCacheService;
|
||||||
|
|
||||||
_cacheState() {
|
_cacheState() {
|
||||||
@ -22,7 +22,7 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
List<String> sharedUserIds,
|
List<String> sharedUserIds,
|
||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
var newAlbum = await _sharedAlbumService.createAlbum(
|
var newAlbum = await _albumService.createAlbum(
|
||||||
albumName,
|
albumName,
|
||||||
assets,
|
assets,
|
||||||
sharedUserIds,
|
sharedUserIds,
|
||||||
@ -47,7 +47,7 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<AlbumResponseDto>? sharedAlbums =
|
List<AlbumResponseDto>? sharedAlbums =
|
||||||
await _sharedAlbumService.getAlbums(isShared: true);
|
await _albumService.getAlbums(isShared: true);
|
||||||
|
|
||||||
if (sharedAlbums != null) {
|
if (sharedAlbums != null) {
|
||||||
state = sharedAlbums;
|
state = sharedAlbums;
|
||||||
@ -61,7 +61,7 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> leaveAlbum(String albumId) async {
|
Future<bool> leaveAlbum(String albumId) async {
|
||||||
var res = await _sharedAlbumService.leaveAlbum(albumId);
|
var res = await _albumService.leaveAlbum(albumId);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
state = state.where((album) => album.id != albumId).toList();
|
state = state.where((album) => album.id != albumId).toList();
|
||||||
@ -76,7 +76,7 @@ class SharedAlbumNotifier extends StateNotifier<List<AlbumResponseDto>> {
|
|||||||
String albumId,
|
String albumId,
|
||||||
List<String> assetIds,
|
List<String> assetIds,
|
||||||
) async {
|
) async {
|
||||||
var res = await _sharedAlbumService.removeAssetFromAlbum(albumId, assetIds);
|
var res = await _albumService.removeAssetFromAlbum(albumId, assetIds);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -96,6 +96,7 @@ class AlbumViewerAppbar extends HookConsumerWidget with PreferredSizeWidget {
|
|||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ref.watch(assetSelectionProvider.notifier).disableMultiselection();
|
ref.watch(assetSelectionProvider.notifier).disableMultiselection();
|
||||||
|
ref.watch(albumProvider.notifier).getAllAlbums();
|
||||||
ref.invalidate(sharedAlbumDetailProvider(albumId));
|
ref.invalidate(sharedAlbumDetailProvider(albumId));
|
||||||
} else {
|
} else {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
@ -3,6 +3,7 @@ import 'package:easy_localization/easy_localization.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
||||||
import 'package:immich_mobile/modules/home/ui/draggable_scrollbar.dart';
|
import 'package:immich_mobile/modules/home/ui/draggable_scrollbar.dart';
|
||||||
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/models/asset_selection_page_result.model.dart';
|
import 'package:immich_mobile/modules/album/models/asset_selection_page_result.model.dart';
|
||||||
@ -62,6 +63,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|||||||
|
|
||||||
if (addAssetsResult != null &&
|
if (addAssetsResult != null &&
|
||||||
addAssetsResult.successfullyAdded > 0) {
|
addAssetsResult.successfullyAdded > 0) {
|
||||||
|
ref.watch(albumProvider.notifier).getAllAlbums();
|
||||||
ref.invalidate(sharedAlbumDetailProvider(albumId));
|
ref.invalidate(sharedAlbumDetailProvider(albumId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
mobile/openapi/lib/model/album_response_dto.dart
generated
BIN
mobile/openapi/lib/model/album_response_dto.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/asset_response_dto.dart
generated
BIN
mobile/openapi/lib/model/asset_response_dto.dart
generated
Binary file not shown.
Loading…
Reference in New Issue
Block a user