Skip to content

Commit

Permalink
Try-catched images copy
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Oct 24, 2017
1 parent 4e07ade commit 4cbf7c0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Unigram/Unigram/ViewModels/DialogViewModel.Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,18 +546,25 @@ private void MessageCopyExecute(TLMessage message)
private async void MessageCopyMediaExecute(TLMessage message)
{
var photo = message.GetPhoto();
if (photo?.Full is TLPhotoSize photoSize)
var photoSize = photo?.Full as TLPhotoSize;
if (photoSize == null)
{
var location = photoSize.Location;
var fileName = string.Format("{0}_{1}_{2}.jpg", location.VolumeId, location.LocalId, location.Secret);
if (File.Exists(FileUtils.GetTempFileName(fileName)))
{
var result = await FileUtils.GetTempFileAsync(fileName);
return;
}

var location = photoSize.Location;
var fileName = string.Format("{0}_{1}_{2}.jpg", location.VolumeId, location.LocalId, location.Secret);
if (File.Exists(FileUtils.GetTempFileName(fileName)))
{
var result = await FileUtils.GetTempFileAsync(fileName);

try
{
var dataPackage = new DataPackage();
dataPackage.SetStorageItems(new[] { result });
ClipboardEx.TrySetContent(dataPackage);
}
catch { }
}
}

Expand Down

0 comments on commit 4cbf7c0

Please sign in to comment.