"Ajout de la gestion des états de frappe avec TypingScope et d'une nouvelle méthode UserSetTypingState."
This commit is contained in:
2
MareAPI
2
MareAPI
Submodule MareAPI updated: 7728ef2390...d105d20507
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MareSynchronos.API.Data.Enum;
|
||||||
using MareSynchronos.API.Data.Extensions;
|
using MareSynchronos.API.Data.Extensions;
|
||||||
using MareSynchronos.API.Dto.User;
|
using MareSynchronos.API.Dto.User;
|
||||||
using MareSynchronosServer.Utils;
|
using MareSynchronosServer.Utils;
|
||||||
@@ -22,7 +23,7 @@ public partial class MareHub
|
|||||||
.SingleAsync(u => u.UID == UserUID)
|
.SingleAsync(u => u.UID == UserUID)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var typingDto = new TypingStateDto(sender.ToUserData(), isTyping);
|
var typingDto = new TypingStateDto(sender.ToUserData(), isTyping, TypingScope.Proximity);
|
||||||
|
|
||||||
await Clients.Caller.Client_UserTypingState(typingDto).ConfigureAwait(false);
|
await Clients.Caller.Client_UserTypingState(typingDto).ConfigureAwait(false);
|
||||||
|
|
||||||
@@ -37,4 +38,35 @@ public partial class MareHub
|
|||||||
|
|
||||||
await Clients.Users(recipients).Client_UserTypingState(typingDto).ConfigureAwait(false);
|
await Clients.Users(recipients).Client_UserTypingState(typingDto).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = "Identified")]
|
||||||
|
public async Task UserSetTypingState(bool isTyping, TypingScope scope)
|
||||||
|
{
|
||||||
|
_logger.LogCallInfo(MareHubLogger.Args(isTyping, scope));
|
||||||
|
|
||||||
|
var sender = await DbContext.Users.AsNoTracking()
|
||||||
|
.SingleAsync(u => u.UID == UserUID)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
var typingDto = new TypingStateDto(sender.ToUserData(), isTyping, scope);
|
||||||
|
|
||||||
|
await Clients.Caller.Client_UserTypingState(typingDto).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (scope == TypingScope.Party || scope == TypingScope.CrossParty)
|
||||||
|
{
|
||||||
|
_logger.LogCallInfo(MareHubLogger.Args("Typing scope is party-based; server-side party routing not yet implemented, not broadcasting to non-caller."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pairedEntries = await GetAllPairedClientsWithPauseState().ConfigureAwait(false);
|
||||||
|
var recipients = pairedEntries
|
||||||
|
.Where(p => !p.IsPaused)
|
||||||
|
.Select(p => p.UID)
|
||||||
|
.Distinct(StringComparer.Ordinal)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (recipients.Count == 0) return;
|
||||||
|
|
||||||
|
await Clients.Users(recipients).Client_UserTypingState(typingDto).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user