Skip to content

Commit

Permalink
Disable the move entry button when the receiving repo is not a write …
Browse files Browse the repository at this point in the history
…replica
  • Loading branch information
J-Pabon committed Nov 8, 2024
1 parent f7e901a commit 940465d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/app/widgets/dialogs/move_entry_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -135,13 +136,19 @@ class _MoveEntryDialogState extends State<MoveEntryDialog> {
BlocBuilder<NavigationCubit, NavigationState>(
bloc: navigationCubit,
builder: (context, state) {
final currentRepoAccessMode =
widget.reposCubit.currentRepo?.accessMode;
final isCurrentRepoWriteMode =
currentRepoAccessMode == AccessMode.write;

final canMove = state.isFolder
? _canMove(
originRepoLocation: originRepoCubit.location,
originPath: repo_path.dirname(entryPath),
destinationRepoLocation: state.repoLocation,
destinationPath: state.path,
isRepoList: isRepoList,
isCurrentRepoWriteMode: isCurrentRepoWriteMode,
)
: false;
return PositiveButton(
Expand Down Expand Up @@ -179,15 +186,18 @@ class _MoveEntryDialogState extends State<MoveEntryDialog> {
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;
Expand Down

0 comments on commit 940465d

Please sign in to comment.