Lots of fix
This commit is contained in:
parent
454b6d5814
commit
16294b7103
@ -6,6 +6,13 @@ using ReactiveUI.SourceGenerators;
|
||||
|
||||
namespace Flawless.Client.Models;
|
||||
|
||||
public enum WebhookEventType
|
||||
{
|
||||
Push,
|
||||
IssueCreated,
|
||||
IssueUpdate
|
||||
}
|
||||
|
||||
public partial class RepositoryModel : ReactiveModel
|
||||
{
|
||||
public static string GetStandaloneName(string name, string ownerName)
|
||||
@ -42,7 +49,7 @@ public partial class RepositoryModel : ReactiveModel
|
||||
Developer = 2,
|
||||
Owner = 3,
|
||||
}
|
||||
|
||||
|
||||
public partial class Webhook : ReactiveModel
|
||||
{
|
||||
[Reactive] private int _id;
|
||||
@ -79,7 +86,7 @@ public partial class RepositoryModel : ReactiveModel
|
||||
|
||||
public partial class Comment : ReactiveModel
|
||||
{
|
||||
[Reactive] private ulong _id;
|
||||
[Reactive] private int _id;
|
||||
|
||||
[Reactive] private string _content;
|
||||
|
||||
@ -87,7 +94,7 @@ public partial class RepositoryModel : ReactiveModel
|
||||
|
||||
[Reactive] private DateTime _createdAt;
|
||||
|
||||
[Reactive] private ulong? _replyTo;
|
||||
[Reactive] private int? _replyTo;
|
||||
}
|
||||
|
||||
public partial class Member : ReactiveModel
|
||||
|
||||
@ -379,13 +379,9 @@ namespace Flawless.Client.Remote
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
public partial class AddCommentRequest
|
||||
{
|
||||
public string Content;
|
||||
|
||||
[JsonPropertyName("content")]
|
||||
public string Content { get; set; }
|
||||
|
||||
[JsonPropertyName("replyTo")]
|
||||
public long? ReplyTo { get; set; }
|
||||
|
||||
public int? ReplyTo;
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
@ -393,7 +389,7 @@ namespace Flawless.Client.Remote
|
||||
{
|
||||
|
||||
[JsonPropertyName("commentId")]
|
||||
public long CommentId { get; set; }
|
||||
public int CommentId { get; set; }
|
||||
|
||||
[JsonPropertyName("author")]
|
||||
public string Author { get; set; }
|
||||
@ -405,7 +401,7 @@ namespace Flawless.Client.Remote
|
||||
public System.DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
[JsonPropertyName("replyToId")]
|
||||
public long? ReplyToId { get; set; }
|
||||
public int? ReplyToId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@ -640,26 +636,6 @@ namespace Flawless.Client.Remote
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
public enum LogLevel
|
||||
{
|
||||
|
||||
_0 = 0,
|
||||
|
||||
_1 = 1,
|
||||
|
||||
_2 = 2,
|
||||
|
||||
_3 = 3,
|
||||
|
||||
_4 = 4,
|
||||
|
||||
_5 = 5,
|
||||
|
||||
_6 = 6,
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
public partial class LoginRequest
|
||||
{
|
||||
@ -911,7 +887,7 @@ namespace Flawless.Client.Remote
|
||||
public string NickName { get; set; }
|
||||
|
||||
[JsonPropertyName("gender")]
|
||||
public int Gender { get; set; }
|
||||
public UserSex Gender { get; set; }
|
||||
|
||||
[JsonPropertyName("bio")]
|
||||
public string Bio { get; set; }
|
||||
@ -946,22 +922,7 @@ namespace Flawless.Client.Remote
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
public partial class WebhookCreateRequest
|
||||
{
|
||||
|
||||
[JsonPropertyName("targetUrl")]
|
||||
public string TargetUrl { get; set; }
|
||||
|
||||
[JsonPropertyName("eventType")]
|
||||
public WebhookEventType EventType { get; set; }
|
||||
|
||||
[JsonPropertyName("secret")]
|
||||
public string Secret { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
public enum WebhookEventType
|
||||
public enum UserSex
|
||||
{
|
||||
|
||||
_0 = 0,
|
||||
@ -970,6 +931,23 @@ namespace Flawless.Client.Remote
|
||||
|
||||
_2 = 2,
|
||||
|
||||
_3 = 3,
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
public partial class WebhookCreateRequest
|
||||
{
|
||||
|
||||
[JsonPropertyName("targetUrl")]
|
||||
public string TargetUrl { get; set; }
|
||||
|
||||
[JsonPropertyName("eventType")]
|
||||
public int EventType { get; set; }
|
||||
|
||||
[JsonPropertyName("secret")]
|
||||
public string Secret { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
|
||||
@ -983,7 +961,7 @@ namespace Flawless.Client.Remote
|
||||
public string TargetUrl { get; set; }
|
||||
|
||||
[JsonPropertyName("eventType")]
|
||||
public WebhookEventType EventType { get; set; }
|
||||
public int EventType { get; set; }
|
||||
|
||||
[JsonPropertyName("isActive")]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
@ -389,11 +389,11 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
|
||||
entity.Comments.AddRange(details.Select(x => new RepositoryModel.Comment
|
||||
{
|
||||
Id = (ulong)x.Key,
|
||||
Id = x.Key,
|
||||
Author = x.Value.Author,
|
||||
Content = x.Value.Content,
|
||||
CreatedAt = x.Value.CreatedAt.UtcDateTime,
|
||||
ReplyTo = x.Value.ReplyToId.HasValue ? (ulong)x.Value.ReplyToId.Value : null
|
||||
ReplyTo = x.Value.ReplyToId.HasValue ? x.Value.ReplyToId.Value : null
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -415,21 +415,21 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
for (var i = 0; i < entity.Comments.Count; i++)
|
||||
{
|
||||
var c = entity.Comments[i];
|
||||
if (!details.ContainsKey((long) c.Id)) repo.Issues.RemoveAt(i);
|
||||
if (!details.ContainsKey(c.Id)) repo.Issues.RemoveAt(i);
|
||||
}
|
||||
|
||||
foreach (var (key, value) in details)
|
||||
{
|
||||
var d = entity.Comments.FirstOrDefault(x => x.Id == (ulong) key);
|
||||
var d = entity.Comments.FirstOrDefault(x => x.Id == key);
|
||||
if (d == null)
|
||||
{
|
||||
var c = new RepositoryModel.Comment
|
||||
{
|
||||
Id = (ulong)key,
|
||||
Id = key,
|
||||
Author = value.Author,
|
||||
Content = value.Content,
|
||||
CreatedAt = value.CreatedAt.UtcDateTime,
|
||||
ReplyTo = value.ReplyToId.HasValue ? (ulong)value.ReplyToId.Value : null
|
||||
ReplyTo = value.ReplyToId.HasValue ? value.ReplyToId.Value : null
|
||||
};
|
||||
|
||||
entity.Comments.Add(c);
|
||||
@ -439,7 +439,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
d.Author = value.Author;
|
||||
d.Content = value.Content;
|
||||
d.CreatedAt = value.CreatedAt.UtcDateTime;
|
||||
d.ReplyTo = value.ReplyToId.HasValue ? (ulong)value.ReplyToId.Value : null;
|
||||
d.ReplyTo = value.ReplyToId.HasValue ? value.ReplyToId.Value : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -550,7 +550,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask<bool> AddCommentAsync(RepositoryModel repo, int issueId, string content, ulong? replyTo)
|
||||
public async ValueTask<bool> AddCommentAsync(RepositoryModel repo, int issueId, string content, int? replyTo)
|
||||
{
|
||||
var api = Api.C;
|
||||
try
|
||||
@ -561,8 +561,12 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
return false;
|
||||
}
|
||||
|
||||
await api.Gateway.Comment(repo.OwnerName, repo.Name, issueId,
|
||||
new AddCommentRequest { Content = content, ReplyTo = replyTo.HasValue ? (long) replyTo.Value : null });
|
||||
var req = new AddCommentRequest
|
||||
{
|
||||
Content = content, ReplyTo = replyTo.HasValue ? replyTo.Value : null
|
||||
};
|
||||
|
||||
await api.Gateway.Comment(repo.OwnerName, repo.Name, issueId, req);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -1445,7 +1449,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
|
||||
wh.TargetUrl = newWh.TargetUrl;
|
||||
wh.Active = newWh.IsActive;
|
||||
wh.EventType = newWh.EventType;
|
||||
wh.EventType = (WebhookEventType) newWh.EventType;
|
||||
}
|
||||
|
||||
foreach (var wh in dict.Values)
|
||||
@ -1456,7 +1460,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
TargetUrl = wh.TargetUrl,
|
||||
Active = wh.IsActive,
|
||||
CreatedAt = wh.CreatedAt.UtcDateTime,
|
||||
EventType = wh.EventType
|
||||
EventType = (WebhookEventType) wh.EventType
|
||||
});
|
||||
}
|
||||
return true;
|
||||
@ -1484,7 +1488,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
new WebhookCreateRequest {
|
||||
TargetUrl = targetUrl,
|
||||
Secret = secret,
|
||||
EventType = evt,
|
||||
EventType = (int) evt,
|
||||
});
|
||||
|
||||
return await UpdateWebhooksFromServerAsync(repo);
|
||||
|
||||
@ -84,9 +84,9 @@ public partial class IssueDetailViewModel : RoutableViewModelBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!await _service.AddCommentAsync(_repo, CurrentIssue.Id, NewComment, _replyTo?.Id ?? null)) return;
|
||||
if (!await _service.AddCommentAsync(_repo, CurrentIssue.Id, NewComment, ReplyTo?.Id ?? null)) return;
|
||||
|
||||
_replyTo = null;
|
||||
ReplyTo = null;
|
||||
NewComment = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using Flawless.Client.Remote;
|
||||
using Flawless.Client.Models;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.SourceGenerators;
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ public partial class RepositoryViewModel : RoutableViewModelBase
|
||||
[Reactive] private ISeries[] _byDay = [new ColumnSeries<DateTimePoint>()];
|
||||
|
||||
public ICartesianAxis[] XAxesByDay { get; set; } = [
|
||||
new DateTimeAxis(TimeSpan.FromDays(1), date => date.ToString("MMMM dd"))
|
||||
new DateTimeAxis(TimeSpan.FromDays(1), date => date.ToString("MM/dd/yyyy"))
|
||||
];
|
||||
|
||||
private string _wsRoot;
|
||||
|
||||
@ -105,7 +105,7 @@
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Stretch" Orientation="Vertical">
|
||||
<Label>Every Day Commits</Label>
|
||||
<lvc:CartesianChart Series="{Binding ByDay, Mode=TwoWay}" XAxes="{Binding XAxesByDay, Mode=TwoWay}">
|
||||
<lvc:CartesianChart MinHeight="280" Series="{Binding ByDay, Mode=TwoWay}" XAxes="{Binding XAxesByDay, Mode=TwoWay}">
|
||||
</lvc:CartesianChart>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Stretch" Orientation="Vertical">
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
namespace Flawless.Communication.Request;
|
||||
|
||||
public record AddCommentRequest(string Content, ulong? ReplyTo);
|
||||
public struct AddCommentRequest
|
||||
{
|
||||
public string Content;
|
||||
|
||||
public int? ReplyTo;
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
namespace Flawless.Communication.Response;
|
||||
|
||||
public record CommentResponse(
|
||||
ulong CommentId,
|
||||
int CommentId,
|
||||
string Author,
|
||||
string Content,
|
||||
DateTime CreatedAt,
|
||||
ulong? ReplyToId = null
|
||||
int? ReplyToId = null
|
||||
);
|
||||
@ -5,7 +5,7 @@ namespace Flawless.Server.Models;
|
||||
|
||||
public class RepositoryIssue
|
||||
{
|
||||
[Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
@ -32,8 +32,8 @@ public class RepositoryIssue
|
||||
|
||||
public class RepositoryIssueContent
|
||||
{
|
||||
[Key, Required]
|
||||
public ulong Id { get; set; }
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public RepositoryIssue Issue { get; set; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user