Fix legacy search page incompatible with new viewer page when opening photos not yet in filescontroller

This commit is contained in:
Ming Ming 2024-10-30 00:12:58 +08:00
parent 7f328b07f9
commit 7dcaf30352
4 changed files with 9 additions and 4 deletions

View file

@ -33,6 +33,7 @@ import 'package:nc_photos/set_as_handler.dart';
import 'package:nc_photos/share_handler.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/disposable.dart';
import 'package:nc_photos/widget/file_content_view.dart';
import 'package:nc_photos/widget/handler/remove_selection_handler.dart';

View file

@ -17,7 +17,7 @@ class _Bloc extends Bloc<_Event, _State>
fileIds: fileIds,
index: startIndex,
currentFile:
filesController.stream.value.dataMap[fileIds[startIndex]]!,
filesController.stream.value.dataMap[fileIds[startIndex]],
appBarButtons: prefController.viewerAppBarButtonsValue,
bottomAppBarButtons: prefController.viewerBottomAppBarButtonsValue,
)) {
@ -139,15 +139,19 @@ class _Bloc extends Bloc<_Event, _State>
_log.info(ev);
final fileId = state.fileIdOrders[ev.index];
final fileState = state.fileStates[fileId] ?? _PageState.create();
final file = state.files[fileId];
emit(state.copyWith(
index: ev.index,
currentFile: state.files[fileId],
currentFile: file,
fileStates: state.fileStates[fileId] == null
? state.fileStates.addedAll({fileId: fileState})
: null,
currentFileState: fileState,
isInitialLoad: false,
));
if (file == null) {
filesController.queryByFileId([fileId]);
}
}
void _onRequestPage(_RequestPage ev, _Emitter emit) {

View file

@ -35,7 +35,7 @@ class _State {
factory _State.init({
required List<int> fileIds,
required int index,
required FileDescriptor currentFile,
required FileDescriptor? currentFile,
required List<ViewerAppBarButtonType> appBarButtons,
required List<ViewerAppBarButtonType> bottomAppBarButtons,
}) =>

View file

@ -229,7 +229,7 @@ class _PageViewState extends State<_PageView> {
builder: (context, file) {
if (file == null) {
return const Center(
child: Text("File not found"),
child: AppIntermediateCircularProgressIndicator(),
);
} else {
return FractionallySizedBox(