From 940465d5f56c975b3a9a80e37b9e5dbf7bc8096e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Pab=C3=B3n?= Date: Fri, 8 Nov 2024 15:53:37 +0800 Subject: [PATCH] Disable the move entry button when the receiving repo is not a write replica --- lib/app/widgets/dialogs/move_entry_bottom_sheet.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/app/widgets/dialogs/move_entry_bottom_sheet.dart b/lib/app/widgets/dialogs/move_entry_bottom_sheet.dart index 9e576263..e0e91419 100644 --- a/lib/app/widgets/dialogs/move_entry_bottom_sheet.dart +++ b/lib/app/widgets/dialogs/move_entry_bottom_sheet.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:ouisync/ouisync.dart' show AccessMode; import '../../../generated/l10n.dart'; import '../../cubits/cubits.dart'; @@ -135,6 +136,11 @@ class _MoveEntryDialogState extends State { BlocBuilder( bloc: navigationCubit, builder: (context, state) { + final currentRepoAccessMode = + widget.reposCubit.currentRepo?.accessMode; + final isCurrentRepoWriteMode = + currentRepoAccessMode == AccessMode.write; + final canMove = state.isFolder ? _canMove( originRepoLocation: originRepoCubit.location, @@ -142,6 +148,7 @@ class _MoveEntryDialogState extends State { destinationRepoLocation: state.repoLocation, destinationPath: state.path, isRepoList: isRepoList, + isCurrentRepoWriteMode: isCurrentRepoWriteMode, ) : false; return PositiveButton( @@ -179,15 +186,18 @@ class _MoveEntryDialogState extends State { required RepoLocation? destinationRepoLocation, required String destinationPath, required bool isRepoList, + required bool isCurrentRepoWriteMode, }) { if (isRepoList) return false; if (destinationRepoLocation == null) return false; + if (!isCurrentRepoWriteMode) return false; bool isSameRepo = originRepoLocation.compareTo(destinationRepoLocation) == 0 ? true : false; final isSamePath = originPath.compareTo(destinationPath) == 0 ? true : false; + if (isSameRepo && isSamePath) return false; return true;