Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@using TelegramDownloader.Models
@using TelegramDownloader.Services
@implements IDisposable

@inject TransactionInfoService tis

<style>
.download-info-modal-overlay {
Expand Down Expand Up @@ -416,13 +419,19 @@
this.downloadModel = downloadModel;
if (this.downloadModel != null)
{
// Live refresh while the modal is open: the model reference is live,
// so re-rendering on the aggregated (throttled) transactions event
// keeps progress, state, duration and speed up to date.
tis.TransactionsChanged -= OnTransactionsChanged;
tis.TransactionsChanged += OnTransactionsChanged;
isVisible = true;
StateHasChanged();
}
}

private async Task HideModal()
{
tis.TransactionsChanged -= OnTransactionsChanged;
isVisible = false;
StateHasChanged();

Expand All @@ -432,6 +441,21 @@
}
}

private async void OnTransactionsChanged(object sender, System.EventArgs e)
{
if (!isVisible) return;
try
{
await InvokeAsync(StateHasChanged);
}
catch { }
}

public void Dispose()
{
tis.TransactionsChanged -= OnTransactionsChanged;
}

private async Task OnOverlayClick()
{
await HideModal();
Expand Down
24 changes: 24 additions & 0 deletions TelegramDownloader/Pages/Modals/InfoModals/TaskInfoModal.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@using TelegramDownloader.Models
@using TelegramDownloader.Services
@implements IDisposable

@inject TransactionInfoService tis

<style>
.task-info-modal-overlay {
Expand Down Expand Up @@ -465,13 +468,19 @@
this.taskModel = taskModel;
if (this.taskModel != null)
{
// Live refresh while the modal is open: the model reference is live,
// so re-rendering on the aggregated (throttled) transactions event
// keeps progress, state, duration and file counters up to date.
tis.TransactionsChanged -= OnTransactionsChanged;
tis.TransactionsChanged += OnTransactionsChanged;
isVisible = true;
StateHasChanged();
}
}

private async Task HideModal()
{
tis.TransactionsChanged -= OnTransactionsChanged;
isVisible = false;
StateHasChanged();

Expand All @@ -481,6 +490,21 @@
}
}

private async void OnTransactionsChanged(object sender, System.EventArgs e)
{
if (!isVisible) return;
try
{
await InvokeAsync(StateHasChanged);
}
catch { }
}

public void Dispose()
{
tis.TransactionsChanged -= OnTransactionsChanged;
}

private async Task OnOverlayClick()
{
await HideModal();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@using TelegramDownloader.Models
@using TelegramDownloader.Services
@implements IDisposable

@inject TransactionInfoService tis

<style>
.upload-modal-overlay {
Expand Down Expand Up @@ -422,13 +425,19 @@
this.uploadModel = uploadModel;
if (this.uploadModel != null)
{
// Live refresh while the modal is open: the model reference is live,
// so re-rendering on the aggregated (throttled) transactions event
// keeps progress, state, duration and speed up to date.
tis.TransactionsChanged -= OnTransactionsChanged;
tis.TransactionsChanged += OnTransactionsChanged;
isVisible = true;
StateHasChanged();
}
}

private async Task HideModal()
{
tis.TransactionsChanged -= OnTransactionsChanged;
isVisible = false;
StateHasChanged();

Expand All @@ -438,6 +447,21 @@
}
}

private async void OnTransactionsChanged(object sender, System.EventArgs e)
{
if (!isVisible) return;
try
{
await InvokeAsync(StateHasChanged);
}
catch { }
}

public void Dispose()
{
tis.TransactionsChanged -= OnTransactionsChanged;
}

private async Task OnOverlayClick()
{
await HideModal();
Expand Down