Repository navigation
Expand file tree
/
Copy pathLFSLocks.cs
More file actions
75 lines (63 loc) · 1.86 KB
/
Copy pathLFSLocks.cs
File metadata and controls
75 lines (63 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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, string remote)
{
_repo = repo;
_remote = remote;
Locks = new AvaloniaList<Models.LFSLock>();
Task.Run(() =>
{
var collect = new Commands.LFS(_repo).Locks(_remote);
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(_remote, lfsLock.ID, force);
Dispatcher.UIThread.Invoke(() =>
{
if (succ)
Locks.Remove(lfsLock);
IsLoading = false;
IsEmpty = Locks.Count == 0;
});
});
}
private string _repo;
private string _remote;
private bool _isLoading = true;
private bool _isEmpty = false;
}
}