This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathInlineCommentThreadModel.cs
More file actions
88 lines (75 loc) · 2.67 KB
/
InlineCommentThreadModel.cs
File metadata and controls
88 lines (75 loc) · 2.67 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
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using GitHub.Extensions;
using GitHub.Models;
using ReactiveUI;
namespace GitHub.InlineReviews.Models
{
/// <summary>
/// Represents a thread of inline comments on an <see cref="IPullRequestSessionFile"/>.
/// </summary>
class InlineCommentThreadModel : ReactiveObject, IInlineCommentThreadModel
{
bool isStale;
int lineNumber = -1;
/// <summary>
/// Initializes a new instance of the <see cref="InlineCommentThreadModel"/> class.
/// </summary>
/// <param name="relativePath">The relative path to the file that the thread is on.</param>
/// <param name="commitSha">The SHA of the commit that the thread appears on.</param>
/// <param name="diffMatch">
/// The last five lines of the thread's diff hunk, in reverse order.
/// </param>
/// <param name="comments">The comments in the thread</param>
public InlineCommentThreadModel(
string relativePath,
string commitSha,
IList<DiffLine> diffMatch,
IEnumerable<InlineCommentModel> comments,
bool isOutdated,
bool isResolved)
{
Guard.ArgumentNotNull(relativePath, nameof(relativePath));
Guard.ArgumentNotNull(commitSha, nameof(commitSha));
Guard.ArgumentNotNull(diffMatch, nameof(diffMatch));
Comments = comments.ToList();
DiffMatch = diffMatch;
DiffLineType = diffMatch[0].Type;
CommitSha = commitSha;
RelativePath = relativePath;
IsOutdated = isOutdated;
IsResolved = isResolved;
foreach (var comment in comments)
{
comment.Thread = this;
}
}
/// <inheritdoc/>
public IReadOnlyList<InlineCommentModel> Comments { get; }
/// <inheritdoc/>
public IList<DiffLine> DiffMatch { get; }
/// <inheritdoc/>
public DiffChangeType DiffLineType { get; }
/// <inheritdoc/>
public bool IsStale
{
get { return isStale; }
set { this.RaiseAndSetIfChanged(ref isStale, value); }
}
/// <inheritdoc/>
public int LineNumber
{
get { return lineNumber; }
set { this.RaiseAndSetIfChanged(ref lineNumber, value); }
}
/// <inheritdoc/>
public string CommitSha { get; }
/// <inheritdoc/>
public string RelativePath { get; }
/// <inheritdoc/>
public bool IsOutdated { get; }
/// <inheritdoc/>
public bool IsResolved { get; }
}
}