mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-21 02:15:00 +00:00
Refactored handling of diff object into separate function
This commit is contained in:
parent
05e2936abf
commit
0cc565d193
1 changed files with 102 additions and 88 deletions
|
@ -7,6 +7,7 @@ using Avalonia.Media.Imaging;
|
|||
using Avalonia.Threading;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SourceGit.Models;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
|
@ -144,6 +145,23 @@ namespace SourceGit.ViewModels
|
|||
|
||||
_info = info;
|
||||
|
||||
var rs = GetDiffObject(latest);
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (_content is Models.TextDiff old && rs is Models.TextDiff cur && old.File == cur.File)
|
||||
cur.ScrollOffset = old.ScrollOffset;
|
||||
|
||||
FileModeChange = latest.FileModeChange;
|
||||
Content = rs;
|
||||
IsLFSDiff = latest.IsLFS;
|
||||
IsTextDiff = rs is Models.TextDiff;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private object GetDiffObject(DiffResult latest)
|
||||
{
|
||||
var rs = null as object;
|
||||
if (latest.TextDiff != null)
|
||||
{
|
||||
|
@ -232,18 +250,14 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
rs = new Models.NoOrEOLChange();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
private string GetLFSObjectPath(string oid)
|
||||
{
|
||||
if (_content is Models.TextDiff old && rs is Models.TextDiff cur && old.File == cur.File)
|
||||
cur.ScrollOffset = old.ScrollOffset;
|
||||
var lfsDir = Path.Combine(".git", "lfs", "objects", oid.Substring(0, 2), oid.Substring(2, 2), oid);
|
||||
|
||||
FileModeChange = latest.FileModeChange;
|
||||
Content = rs;
|
||||
IsLFSDiff = latest.IsLFS;
|
||||
IsTextDiff = rs is Models.TextDiff;
|
||||
});
|
||||
});
|
||||
return lfsDir;
|
||||
}
|
||||
|
||||
private (Bitmap, long) BitmapFromRevisionFile(string repo, string revision, string file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue