mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +01:00
Fix set/unsetting favorite in viewer does not reflect in browser
This commit is contained in:
parent
962829568f
commit
b7c0b187e2
1 changed files with 38 additions and 43 deletions
|
@ -22,14 +22,11 @@ import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
import 'package:nc_photos/entity/pref.dart';
|
import 'package:nc_photos/entity/pref.dart';
|
||||||
import 'package:nc_photos/flutter_util.dart';
|
import 'package:nc_photos/flutter_util.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/notified_action.dart';
|
|
||||||
import 'package:nc_photos/object_extension.dart';
|
import 'package:nc_photos/object_extension.dart';
|
||||||
import 'package:nc_photos/platform/features.dart' as features;
|
import 'package:nc_photos/platform/features.dart' as features;
|
||||||
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';
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/use_case/inflate_file_descriptor.dart';
|
|
||||||
import 'package:nc_photos/use_case/update_property.dart';
|
|
||||||
import 'package:nc_photos/widget/disposable.dart';
|
import 'package:nc_photos/widget/disposable.dart';
|
||||||
import 'package:nc_photos/widget/handler/archive_selection_handler.dart';
|
import 'package:nc_photos/widget/handler/archive_selection_handler.dart';
|
||||||
import 'package:nc_photos/widget/handler/remove_selection_handler.dart';
|
import 'package:nc_photos/widget/handler/remove_selection_handler.dart';
|
||||||
|
@ -537,32 +534,31 @@ class _ViewerState extends State<Viewer>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final fd = _streamFilesView[_viewerController.currentPage];
|
|
||||||
final c = KiwiContainer().resolve<DiContainer>();
|
|
||||||
final file = (await InflateFileDescriptor(c)(widget.account, [fd])).first;
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_pageStates[index]!.favoriteOverride = true;
|
_pageStates[index]!.favoriteOverride = true;
|
||||||
});
|
});
|
||||||
_pageStates[index]!.isProcessingFavorite = true;
|
_pageStates[index]!.isProcessingFavorite = true;
|
||||||
|
final fd = _streamFilesView[_viewerController.currentPage];
|
||||||
try {
|
try {
|
||||||
await NotifiedAction(
|
await context.read<AccountController>().filesController.updateProperty(
|
||||||
() => UpdateProperty(c)(
|
[fd],
|
||||||
widget.account,
|
isFavorite: true,
|
||||||
file,
|
errorBuilder: (fileIds) {
|
||||||
favorite: true,
|
if (mounted) {
|
||||||
),
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
null,
|
content: Text(L10n.global().unfavoriteFailureNotification),
|
||||||
L10n.global().favoriteSuccessNotification,
|
duration: k.snackBarDurationNormal,
|
||||||
failureText: L10n.global().favoriteFailureNotification,
|
));
|
||||||
)();
|
setState(() {
|
||||||
} catch (e, stackTrace) {
|
_pageStates[index]!.favoriteOverride = false;
|
||||||
_log.shout(
|
});
|
||||||
"[_onFavoritePressed] Failed while UpdateProperty", e, stackTrace);
|
}
|
||||||
setState(() {
|
return null;
|
||||||
_pageStates[index]!.favoriteOverride = false;
|
},
|
||||||
});
|
);
|
||||||
|
} finally {
|
||||||
|
_pageStates[index]!.isProcessingFavorite = false;
|
||||||
}
|
}
|
||||||
_pageStates[index]!.isProcessingFavorite = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onUnfavoritePressed(int index) async {
|
Future<void> _onUnfavoritePressed(int index) async {
|
||||||
|
@ -571,32 +567,31 @@ class _ViewerState extends State<Viewer>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final fd = _streamFilesView[_viewerController.currentPage];
|
|
||||||
final c = KiwiContainer().resolve<DiContainer>();
|
|
||||||
final file = (await InflateFileDescriptor(c)(widget.account, [fd])).first;
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_pageStates[index]!.favoriteOverride = false;
|
_pageStates[index]!.favoriteOverride = false;
|
||||||
});
|
});
|
||||||
_pageStates[index]!.isProcessingFavorite = true;
|
_pageStates[index]!.isProcessingFavorite = true;
|
||||||
|
final fd = _streamFilesView[_viewerController.currentPage];
|
||||||
try {
|
try {
|
||||||
await NotifiedAction(
|
await context.read<AccountController>().filesController.updateProperty(
|
||||||
() => UpdateProperty(c)(
|
[fd],
|
||||||
widget.account,
|
isFavorite: false,
|
||||||
file,
|
errorBuilder: (fileIds) {
|
||||||
favorite: false,
|
if (mounted) {
|
||||||
),
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
null,
|
content: Text(L10n.global().unfavoriteFailureNotification),
|
||||||
L10n.global().unfavoriteSuccessNotification,
|
duration: k.snackBarDurationNormal,
|
||||||
failureText: L10n.global().unfavoriteFailureNotification,
|
));
|
||||||
)();
|
setState(() {
|
||||||
} catch (e, stackTrace) {
|
_pageStates[index]!.favoriteOverride = true;
|
||||||
_log.shout(
|
});
|
||||||
"[_onUnfavoritePressed] Failed while UpdateProperty", e, stackTrace);
|
}
|
||||||
setState(() {
|
return null;
|
||||||
_pageStates[index]!.favoriteOverride = true;
|
},
|
||||||
});
|
);
|
||||||
|
} finally {
|
||||||
|
_pageStates[index]!.isProcessingFavorite = false;
|
||||||
}
|
}
|
||||||
_pageStates[index]!.isProcessingFavorite = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDetailsPressed() {
|
void _onDetailsPressed() {
|
||||||
|
|
Loading…
Reference in a new issue