mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-26 03:40:45 +08:00
- Remove all synchronous method in commands - `Command.ReadToEndAsync` now is protected method - Rename `ResultAsync` to `GetResultAsync` - Call `ConfigureAwait(false)` when there's no context Signed-off-by: leo <longshuang@msn.cn>
35 lines
1018 B
C#
35 lines
1018 B
C#
using System.Threading.Tasks;
|
|
using Avalonia.Threading;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
namespace SourceGit.ViewModels
|
|
{
|
|
public class RevisionLFSImage : ObservableObject
|
|
{
|
|
public Models.RevisionLFSObject LFS
|
|
{
|
|
get;
|
|
}
|
|
|
|
public Models.RevisionImageFile Image
|
|
{
|
|
get => _image;
|
|
private set => SetProperty(ref _image, value);
|
|
}
|
|
|
|
public RevisionLFSImage(string repo, string file, Models.LFSObject lfs, Models.ImageDecoder decoder)
|
|
{
|
|
LFS = new Models.RevisionLFSObject() { Object = lfs };
|
|
|
|
Task.Run(async () =>
|
|
{
|
|
var source = await ImageSource.FromLFSObjectAsync(repo, lfs, decoder).ConfigureAwait(false);
|
|
var img = new Models.RevisionImageFile(file, source.Bitmap, source.Size);
|
|
Dispatcher.UIThread.Invoke(() => Image = img);
|
|
});
|
|
}
|
|
|
|
private Models.RevisionImageFile _image = null;
|
|
}
|
|
}
|