mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
refactor: rewrite SetDetail
for selected working copy changes (#328)
This commit is contained in:
parent
e50db02ea8
commit
3506df40e0
1 changed files with 15 additions and 18 deletions
|
@ -135,7 +135,7 @@ namespace SourceGit.ViewModels
|
||||||
if (value == null || value.Count == 0)
|
if (value == null || value.Count == 0)
|
||||||
{
|
{
|
||||||
if (_selectedStaged == null || _selectedStaged.Count == 0)
|
if (_selectedStaged == null || _selectedStaged.Count == 0)
|
||||||
SetDetail(null);
|
SetDetail(null, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -143,9 +143,9 @@ namespace SourceGit.ViewModels
|
||||||
SelectedStaged = [];
|
SelectedStaged = [];
|
||||||
|
|
||||||
if (value.Count == 1)
|
if (value.Count == 1)
|
||||||
SetDetail(value[0]);
|
SetDetail(value[0], true);
|
||||||
else
|
else
|
||||||
SetDetail(null);
|
SetDetail(null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace SourceGit.ViewModels
|
||||||
if (value == null || value.Count == 0)
|
if (value == null || value.Count == 0)
|
||||||
{
|
{
|
||||||
if (_selectedUnstaged == null || _selectedUnstaged.Count == 0)
|
if (_selectedUnstaged == null || _selectedUnstaged.Count == 0)
|
||||||
SetDetail(null);
|
SetDetail(null, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -169,9 +169,9 @@ namespace SourceGit.ViewModels
|
||||||
SelectedUnstaged = [];
|
SelectedUnstaged = [];
|
||||||
|
|
||||||
if (value.Count == 1)
|
if (value.Count == 1)
|
||||||
SetDetail(value[0]);
|
SetDetail(value[0], false);
|
||||||
else
|
else
|
||||||
SetDetail(null);
|
SetDetail(null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,9 +224,11 @@ namespace SourceGit.ViewModels
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
if (_selectedUnstaged.Count == 1)
|
if (_selectedUnstaged.Count == 1)
|
||||||
SetDetail(_selectedUnstaged[0]);
|
SetDetail(_selectedUnstaged[0], true);
|
||||||
else if (_selectedStaged.Count == 1)
|
else if (_selectedStaged.Count == 1)
|
||||||
SetDetail(_selectedStaged[0]);
|
SetDetail(_selectedStaged[0], false);
|
||||||
|
else
|
||||||
|
SetDetail(null, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
return _cached.Find(x => x.IsConflit) != null;
|
return _cached.Find(x => x.IsConflit) != null;
|
||||||
|
@ -283,11 +285,11 @@ namespace SourceGit.ViewModels
|
||||||
_isLoadingData = false;
|
_isLoadingData = false;
|
||||||
|
|
||||||
if (selectedUnstaged.Count == 1)
|
if (selectedUnstaged.Count == 1)
|
||||||
SetDetail(selectedUnstaged[0]);
|
SetDetail(selectedUnstaged[0], true);
|
||||||
else if (selectedStaged.Count == 1)
|
else if (selectedStaged.Count == 1)
|
||||||
SetDetail(selectedStaged[0]);
|
SetDetail(selectedStaged[0], false);
|
||||||
else
|
else
|
||||||
SetDetail(null);
|
SetDetail(null, false);
|
||||||
|
|
||||||
// Try to load merge message from MERGE_MSG
|
// Try to load merge message from MERGE_MSG
|
||||||
if (string.IsNullOrEmpty(_commitMessage))
|
if (string.IsNullOrEmpty(_commitMessage))
|
||||||
|
@ -332,7 +334,6 @@ namespace SourceGit.ViewModels
|
||||||
if (_unstaged.Count == 0 || changes.Count == 0)
|
if (_unstaged.Count == 0 || changes.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetDetail(null);
|
|
||||||
IsStaging = true;
|
IsStaging = true;
|
||||||
_repo.SetWatcherEnabled(false);
|
_repo.SetWatcherEnabled(false);
|
||||||
if (changes.Count == _unstaged.Count)
|
if (changes.Count == _unstaged.Count)
|
||||||
|
@ -370,7 +371,6 @@ namespace SourceGit.ViewModels
|
||||||
if (_staged.Count == 0 || changes.Count == 0)
|
if (_staged.Count == 0 || changes.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetDetail(null);
|
|
||||||
IsUnstaging = true;
|
IsUnstaging = true;
|
||||||
_repo.SetWatcherEnabled(false);
|
_repo.SetWatcherEnabled(false);
|
||||||
if (_useAmend)
|
if (_useAmend)
|
||||||
|
@ -1170,12 +1170,11 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDetail(Models.Change change)
|
private void SetDetail(Models.Change change, bool isUnstaged)
|
||||||
{
|
{
|
||||||
if (_isLoadingData)
|
if (_isLoadingData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var isUnstaged = _selectedUnstaged != null && _selectedUnstaged.Count > 0;
|
|
||||||
if (change == null)
|
if (change == null)
|
||||||
DetailContext = null;
|
DetailContext = null;
|
||||||
else if (change.IsConflit && isUnstaged)
|
else if (change.IsConflit && isUnstaged)
|
||||||
|
@ -1258,10 +1257,8 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_repo.Settings.PushCommitMessage(_commitMessage);
|
|
||||||
|
|
||||||
SetDetail(null);
|
|
||||||
IsCommitting = true;
|
IsCommitting = true;
|
||||||
|
_repo.Settings.PushCommitMessage(_commitMessage);
|
||||||
_repo.SetWatcherEnabled(false);
|
_repo.SetWatcherEnabled(false);
|
||||||
|
|
||||||
var autoStage = AutoStageBeforeCommit;
|
var autoStage = AutoStageBeforeCommit;
|
||||||
|
|
Loading…
Reference in a new issue