-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d02417c
commit 59d7857
Showing
9 changed files
with
117 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
namespace Jordnaer.Shared; | ||
|
||
public class ChatDto | ||
{ | ||
public Guid Id { get; init; } | ||
|
||
/// <summary> | ||
/// The display name of the chat. | ||
/// <para> | ||
/// This defaults to a concatenated string of recipient names. | ||
/// </para> | ||
/// </summary> | ||
public string? DisplayName { get; init; } | ||
|
||
public int UnreadMessageCount { get; set; } | ||
|
||
public List<ChatMessageDto> Messages { get; set; } = new(); | ||
public List<UserSlim> Recipients { get; init; } = new(); | ||
|
||
public DateTime LastMessageSentUtc { get; init; } | ||
public DateTime StartedUtc { get; init; } = DateTime.UtcNow; | ||
public bool HasUnreadMessages => UnreadMessageCount > 0; | ||
{ | ||
public Guid Id { get; init; } | ||
|
||
/// <summary> | ||
/// The display name of the chat. | ||
/// <para> | ||
/// This defaults to a concatenated string of recipient names. | ||
/// </para> | ||
/// </summary> | ||
public string? DisplayName { get; init; } | ||
|
||
public int UnreadMessageCount { get; set; } | ||
|
||
public List<ChatMessageDto> Messages { get; set; } = []; | ||
public List<UserSlim> Recipients { get; init; } = []; | ||
|
||
public DateTime LastMessageSentUtc { get; init; } | ||
public DateTime StartedUtc { get; init; } = DateTime.UtcNow; | ||
public bool HasUnreadMessages => UnreadMessageCount > 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace Jordnaer.Shared; | ||
|
||
public class ChatMessageResult | ||
{ | ||
public List<ChatMessageDto> ChatMessages { get; init; } = new(); | ||
|
||
public int TotalCount { get; init; } | ||
{ | ||
public List<ChatMessageDto> ChatMessages { get; init; } = []; | ||
|
||
public int TotalCount { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace Jordnaer.Shared; | ||
|
||
public class ChatResult | ||
{ | ||
public List<ChatDto> Chats { get; init; } = new(); | ||
|
||
public int TotalCount { get; init; } | ||
{ | ||
public List<ChatDto> Chats { get; init; } = []; | ||
|
||
public int TotalCount { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
namespace Jordnaer.Shared; | ||
|
||
public static class ChatExtensions | ||
{ | ||
public static ChatDto ToChatDto(this Chat chat) => | ||
new() | ||
{ | ||
DisplayName = chat.DisplayName, | ||
Id = chat.Id, | ||
LastMessageSentUtc = chat.LastMessageSentUtc, | ||
StartedUtc = chat.StartedUtc, | ||
Recipients = chat.Recipients.Count == 0 | ||
? new List<UserSlim>() | ||
: chat.Recipients.Select(recipient => recipient.ToUserSlim()).ToList(), | ||
Messages = chat.Messages.Count == 0 | ||
? new List<ChatMessageDto>() | ||
: chat.Messages.Select(chatMessage => chatMessage.ToChatMessageDto()).ToList() | ||
}; | ||
{ | ||
public static ChatDto ToChatDto(this Chat chat) => | ||
new() | ||
{ | ||
DisplayName = chat.DisplayName, | ||
Id = chat.Id, | ||
LastMessageSentUtc = chat.LastMessageSentUtc, | ||
StartedUtc = chat.StartedUtc, | ||
Recipients = chat.Recipients.Count == 0 | ||
? [] | ||
: chat.Recipients.Select(recipient => recipient.ToUserSlim()).ToList(), | ||
Messages = chat.Messages.Count == 0 | ||
? [] | ||
: chat.Messages.Select(chatMessage => chatMessage.ToChatMessageDto()).ToList() | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters