Skip to content

Commit

Permalink
Handle local files that doesn't need to be downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
dotMorten committed Jun 4, 2024
1 parent bd40a7a commit b0ce997
Showing 1 changed file with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,32 @@ private void PopupBackground_MouseDown(object sender, System.Windows.Input.Mouse

private async void popupViewer_PopupAttachmentClicked(object sender, UI.Controls.PopupAttachmentClickedEventArgs e)
{
try
if (!e.Attachment.IsLocal) // Attachment hasn't been downloaded
{
// Make first click just load the attachment (or cancel a loading operation). Otherwise fallback to default behavior
if (e.Attachment.LoadStatus == LoadStatus.NotLoaded)
{
e.Handled = true;
await e.Attachment.LoadAsync();
}
else if (e.Attachment.LoadStatus == LoadStatus.FailedToLoad)
try
{
e.Handled = true;
await e.Attachment.RetryLoadAsync();
// Make first click just load the attachment (or cancel a loading operation). Otherwise fallback to default behavior
if (e.Attachment.LoadStatus == LoadStatus.NotLoaded)
{
e.Handled = true;
await e.Attachment.LoadAsync();
}
else if (e.Attachment.LoadStatus == LoadStatus.FailedToLoad)
{
e.Handled = true;
await e.Attachment.RetryLoadAsync();
}
else if (e.Attachment.LoadStatus == LoadStatus.Loading)
{
e.Handled = true;
e.Attachment.CancelLoad();
}
}
else if (e.Attachment.LoadStatus == LoadStatus.Loading)
catch (Exception ex)
{
e.Handled = true;
e.Attachment.CancelLoad();
MessageBox.Show("Failed to download attachment", ex.Message);
}
}
catch (Exception ex)
{
MessageBox.Show("Failed to download attachment", ex.Message);
}
}
}
}

0 comments on commit b0ce997

Please sign in to comment.