Public Access
Transfers: say so when a drop or a download is refused because the screen is busy
This commit is contained in:
1 parent
cc3d46f78c
commit
36fb0817a4
2 files changed
+41
-6
No files matched your search
@@ -2289,6 +2289,10 @@ internal sealed partial class TransfersViewModel : ObservableObject, IAsyncDispo
|
||||
|
||||
// ---- Moving files ----
|
||||
|
||||
/// <summary>What a transfer asked for while another command is still running is told.</summary>
|
||||
private const string StillBusy =
|
||||
"Still working on the last request. Nothing was queued — try again when it has finished.";
|
||||
|
||||
/// <summary>Queues the chosen remote file for download into the local directory showing.</summary>
|
||||
[RelayCommand]
|
||||
private void Download()
|
||||
@@ -2306,7 +2310,8 @@ internal sealed partial class TransfersViewModel : ObservableObject, IAsyncDispo
|
||||
await QueueDownloadsAsync(rows, CancellationToken.None).ConfigureAwait(true);
|
||||
|
||||
ClearRemoteChecks();
|
||||
});
|
||||
},
|
||||
StillBusy);
|
||||
}
|
||||
|
||||
/// <summary>Queues the chosen local file for upload into the remote directory showing.</summary>
|
||||
@@ -2328,7 +2333,8 @@ internal sealed partial class TransfersViewModel : ObservableObject, IAsyncDispo
|
||||
await QueueUploadsAsync(paths, CancellationToken.None).ConfigureAwait(true);
|
||||
|
||||
ClearLocalChecks();
|
||||
});
|
||||
},
|
||||
StillBusy);
|
||||
}
|
||||
|
||||
/// <summary>Unticks everything on the host's side.</summary>
|
||||
@@ -2393,13 +2399,15 @@ internal sealed partial class TransfersViewModel : ObservableObject, IAsyncDispo
|
||||
internal void QueueUploads(IReadOnlyList<string> paths) =>
|
||||
_ = RunAsync(
|
||||
"Working out what to upload…",
|
||||
() => QueueUploadsAsync(paths, CancellationToken.None));
|
||||
() => QueueUploadsAsync(paths, CancellationToken.None),
|
||||
StillBusy);
|
||||
|
||||
/// <inheritdoc cref="QueueUploads" />
|
||||
internal void QueueDownloads(IReadOnlyList<RemoteEntryRowViewModel> rows) =>
|
||||
_ = RunAsync(
|
||||
"Working out what to download…",
|
||||
() => QueueDownloadsAsync(rows, CancellationToken.None));
|
||||
() => QueueDownloadsAsync(rows, CancellationToken.None),
|
||||
StillBusy);
|
||||
|
||||
internal async Task QueueUploadsAsync(IReadOnlyList<string> paths, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -2580,7 +2588,8 @@ internal sealed partial class TransfersViewModel : ObservableObject, IAsyncDispo
|
||||
|
||||
_ = RunAsync(
|
||||
"Working out what to upload…",
|
||||
() => QueueUploadsAsync(paths, CancellationToken.None));
|
||||
() => QueueUploadsAsync(paths, CancellationToken.None),
|
||||
StillBusy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4154,11 +4163,21 @@ internal sealed partial class TransfersViewModel : ObservableObject, IAsyncDispo
|
||||
/// The same funnel <c>VaultViewModel</c> uses, and here for the same reason: every command on this screen
|
||||
/// can fail with a path the server refused, and one that forgot to clear the busy flag would leave the
|
||||
/// pane permanently disabled.
|
||||
/// <para>
|
||||
/// <paramref name="refusedWhileBusy"/> is for the commands somebody can fire while another is running —
|
||||
/// a drop, or the download and upload buttons pressed twice — which used to vanish without a word: the
|
||||
/// files were not queued and nothing said so. A command given one says why it did nothing instead.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
private async Task RunAsync(string busyMessage, Func<Task> work)
|
||||
private async Task RunAsync(string busyMessage, Func<Task> work, string? refusedWhileBusy = null)
|
||||
{
|
||||
if (IsBusy)
|
||||
{
|
||||
if (refusedWhileBusy is not null)
|
||||
{
|
||||
Status = refusedWhileBusy;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user