mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 13:14:59 +00:00
enhance: Git LFS support
This commit is contained in:
parent
e731807c91
commit
9a0b10bd9c
24 changed files with 780 additions and 34 deletions
73
src/ViewModels/LFSLocks.cs
Normal file
73
src/ViewModels/LFSLocks.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Threading;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class LFSLocks : ObservableObject
|
||||
{
|
||||
public bool IsLoading
|
||||
{
|
||||
get => _isLoading;
|
||||
private set => SetProperty(ref _isLoading, value);
|
||||
}
|
||||
|
||||
public bool IsEmpty
|
||||
{
|
||||
get => _isEmpty;
|
||||
private set => SetProperty(ref _isEmpty, value);
|
||||
}
|
||||
|
||||
public AvaloniaList<Models.LFSLock> Locks
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public LFSLocks(string repo)
|
||||
{
|
||||
_repo = repo;
|
||||
Locks = new AvaloniaList<Models.LFSLock>();
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var collect = new Commands.LFS(_repo).Locks();
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
if (collect.Count > 0)
|
||||
Locks.AddRange(collect);
|
||||
|
||||
IsLoading = false;
|
||||
IsEmpty = collect.Count == 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void Unlock(Models.LFSLock lfsLock, bool force)
|
||||
{
|
||||
if (_isLoading)
|
||||
return;
|
||||
|
||||
IsLoading = true;
|
||||
Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.LFS(_repo).Unlock(lfsLock.ID, force);
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
if (succ)
|
||||
Locks.Remove(lfsLock);
|
||||
|
||||
IsLoading = false;
|
||||
IsEmpty = Locks.Count == 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private string _repo = string.Empty;
|
||||
private bool _isLoading = true;
|
||||
private bool _isEmpty = false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue