Skip to content

Commit 878adb4

Browse files
committed
Fixed Google Drive enumeration
1 parent 04a7042 commit 878adb4

8 files changed

Lines changed: 31 additions & 23 deletions

File tree

src/Platforms/SecureFolderFS.Maui/Views/MainPage.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,15 @@
154154
<Grid Grid.Column="2" Margin="0,0,8,0">
155155
<mi:MauiIcon
156156
Icon="{mi_material:Material ChevronRight}"
157+
IconColor="{AppThemeBinding Light={StaticResource PrimaryContrastingLightColor},
158+
Dark={StaticResource PrimaryContrastingDarkColor}}"
157159
IconSize="16"
158160
OnPlatforms="Android"
159161
Opacity="0.8" />
160162
<mi:MauiIcon
161163
Icon="{mi_cupertino:Cupertino ChevronRight}"
164+
IconColor="{AppThemeBinding Light={StaticResource PrimaryContrastingLightColor},
165+
Dark={StaticResource PrimaryContrastingDarkColor}}"
162166
IconSize="16"
163167
OnPlatforms="iOS"
164168
Opacity="0.8" />

src/Platforms/SecureFolderFS.Maui/Views/Modals/Wizard/MainWizardPage.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public partial class MainWizardPage : BaseModalPage, IOverlayControl
3131
private readonly List<IViewable> _views;
3232
private readonly INavigation _sourceNavigation;
3333
private readonly TaskCompletionSource<IResult> _modalTcs;
34-
private IStagingView? _previousView;
34+
private IViewDesignation? _previousView;
3535

3636
public MainWizardViewModel? ViewModel { get; private set; }
3737

@@ -286,7 +286,7 @@ private async void ViewModel_NavigationRequested(object? sender, NavigationReque
286286
return;
287287

288288
_previousView = OverlayViewModel.CurrentViewModel;
289-
OverlayViewModel.CurrentViewModel = nextViewModel as IStagingView;
289+
OverlayViewModel.CurrentViewModel = nextViewModel as IViewDesignation;
290290

291291
await Navigation.PushAsync(page, true);
292292
e.TaskCompletion?.TrySetResult(true);

src/Sdk/SecureFolderFS.Sdk.GoogleDrive/Storage/GDriveStorable.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace SecureFolderFS.Sdk.GoogleDrive.Storage
88
{
99
public abstract class GDriveStorable : IStorableChild
1010
{
11+
public const string ROOT_ID = "root";
12+
1113
/// <summary>
1214
/// Gets the ID of the object that can exist independently of the parent context.
1315
/// </summary>
@@ -39,7 +41,13 @@ protected GDriveStorable(DriveService driveService, string id, string name, IFol
3941
Id = id;
4042
Name = name;
4143
ParentFolder = parent;
42-
DetachedId = Path.GetFileName(Id);
44+
45+
// Google Drive root can be represented as an empty path segment in app code.
46+
// Normalize it so API queries always use the canonical root alias.
47+
var normalizedId = Id.TrimEnd('/');
48+
DetachedId = string.IsNullOrEmpty(normalizedId)
49+
? ROOT_ID
50+
: Path.GetFileName(normalizedId);
4351
}
4452

4553
/// <inheritdoc/>

src/Sdk/SecureFolderFS.Sdk.GoogleDrive/ViewModels/GDriveAccountViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private async Task<UserCredential> AuthorizeAsync(string userId, bool forcePromp
305305

306306
private static IFolder GetRootGDriveFolder(DriveService driveService)
307307
{
308-
return new GDriveFolder(driveService, string.Empty, "Drive");
308+
return new GDriveFolder(driveService, GDriveStorable.ROOT_ID, "Drive");
309309
}
310310

311311
public static void AssertApiAccess()

src/Sdk/SecureFolderFS.Sdk/ViewModels/Controls/Storage/Browser/FolderViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async Task ListContentsAsync(CancellationToken cancellationToken = defaul
8383
Items.Clear();
8484

8585
var isPickingFolder = BrowserViewModel.TransferViewModel?.IsPickingFolder ?? false;
86-
var items = await Folder.GetItemsAsync(StorableType.All, cancellationToken).ToArrayAsyncImpl(cancellationToken: cancellationToken);
86+
var items = await Folder.GetItemsAsync(isPickingFolder ? StorableType.Folder : StorableType.All, cancellationToken).ToArrayAsyncImpl(cancellationToken: cancellationToken);
8787
BrowserViewModel.Layouts.GetSorter().SortCollection(items.Where(x => !isPickingFolder || x is IFolder).Select(x => (BrowserItemViewModel)(x switch
8888
{
8989
IFile file => new FileViewModel(file, BrowserViewModel, this),

src/Sdk/SecureFolderFS.Sdk/ViewModels/Views/Overlays/WizardOverlayViewModel.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace SecureFolderFS.Sdk.ViewModels.Views.Overlays
1616
[Bindable(true)]
1717
public sealed partial class WizardOverlayViewModel : OverlayViewModel, IStagingView, INavigatable, IDisposable
1818
{
19-
[ObservableProperty] private IStagingView? _CurrentViewModel;
19+
[ObservableProperty] private IViewDesignation? _CurrentViewModel;
2020

2121
public IVaultCollectionModel VaultCollectionModel { get; }
2222

@@ -40,10 +40,10 @@ public override void OnDisappearing()
4040
/// <inheritdoc />
4141
public async Task<IResult> TryContinueAsync(CancellationToken cancellationToken)
4242
{
43-
if (CurrentViewModel is null)
43+
if (CurrentViewModel is not IStagingView stagingView)
4444
return Result.Failure(null);
4545

46-
var result = await CurrentViewModel.TryContinueAsync(cancellationToken);
46+
var result = await stagingView.TryContinueAsync(cancellationToken);
4747
if (result.Successful)
4848
NavigationRequested?.Invoke(this, new WizardNavigationRequestedEventArgs(result, CurrentViewModel));
4949

@@ -53,10 +53,10 @@ public async Task<IResult> TryContinueAsync(CancellationToken cancellationToken)
5353
/// <inheritdoc />
5454
public async Task<IResult> TryCancelAsync(CancellationToken cancellationToken)
5555
{
56-
if (CurrentViewModel is null)
56+
if (CurrentViewModel is not IStagingView stagingView)
5757
return Result.Failure(null);
5858

59-
var result = await CurrentViewModel.TryCancelAsync(cancellationToken);
59+
var result = await stagingView.TryCancelAsync(cancellationToken);
6060
if (result.Successful)
6161
NavigationRequested?.Invoke(this, new DismissNavigationRequestedEventArgs(CurrentViewModel));
6262

@@ -78,26 +78,22 @@ private async Task CancellationAsync(IEventDispatch? eventDispatch, Cancellation
7878
eventDispatch?.PreventForwarding();
7979
}
8080

81-
partial void OnCurrentViewModelChanging(IStagingView? oldValue, IStagingView? newValue)
81+
partial void OnCurrentViewModelChanging(IViewDesignation? oldValue, IViewDesignation? newValue)
8282
{
83-
if (oldValue is not null)
84-
{
85-
oldValue.PropertyChanged -= CurrentViewModel_PropertyChanged;
86-
oldValue.OnDisappearing();
87-
}
83+
oldValue?.PropertyChanged -= CurrentViewModel_PropertyChanged;
84+
oldValue?.OnDisappearing();
85+
86+
newValue?.PropertyChanged += CurrentViewModel_PropertyChanged;
87+
newValue?.OnAppearing();
88+
Title = newValue?.Title;
8889

8990
if (newValue is OverlayViewModel overlayViewModel)
9091
{
91-
overlayViewModel.PropertyChanged += CurrentViewModel_PropertyChanged;
92-
overlayViewModel.OnAppearing();
93-
9492
CanContinue = overlayViewModel.CanContinue;
9593
CanCancel = overlayViewModel.CanCancel;
9694
PrimaryText = overlayViewModel.PrimaryText;
9795
SecondaryText = overlayViewModel.SecondaryText;
9896
}
99-
100-
Title = newValue?.Title;
10197
}
10298

10399
private void CurrentViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)

src/Sdk/SecureFolderFS.Sdk/ViewModels/Views/Vault/BrowserViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using SecureFolderFS.Sdk.Enums;
88
using SecureFolderFS.Sdk.Extensions;
99
using SecureFolderFS.Sdk.Services;
10-
using SecureFolderFS.Sdk.ViewModels.Controls;
1110
using SecureFolderFS.Sdk.ViewModels.Controls.Storage;
1211
using SecureFolderFS.Sdk.ViewModels.Controls.Storage.Browser;
1312
using SecureFolderFS.Sdk.ViewModels.Controls.Transfer;
@@ -101,6 +100,7 @@ public override void OnDisappearing()
101100

102101
try
103102
{
103+
TransferViewModel.IsPickingFolder = true;
104104
await OuterNavigator.NavigateAsync(this);
105105
using var cts = TransferViewModel.GetCancellation(cancellationToken);
106106
return await TransferViewModel.PickFolderAsync(new TransferOptions(TransferType.Select), false, cts.Token);
@@ -111,6 +111,7 @@ public override void OnDisappearing()
111111
}
112112
finally
113113
{
114+
TransferViewModel.IsPickingFolder = false;
114115
await OuterNavigator.GoBackAsync();
115116
Dispose();
116117
}

src/Sdk/SecureFolderFS.Sdk/ViewModels/Views/Wizard/DataSources/AccountSourceWizardViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ private async Task SelectAccountAsync(AccountViewModel? accountViewModel, Cancel
168168
var browser = BrowserHelpers.CreateBrowser(rootFolder, new FileSystemOptions(), accountViewModel, outerNavigator: this);
169169

170170
// Prompt the user to pick a folder
171-
browser.OnAppearing();
172171
_selectedFolder = await browser.PickFolderAsync(null, true, cancellationToken);
173172
if (_selectedFolder is null)
174173
return;

0 commit comments

Comments
 (0)