fixes issue where character hash of paused users in a syncshell was uselessly sent

This commit is contained in:
rootdarkarchon
2022-11-14 01:56:45 +01:00
parent d3034d7c22
commit 0f697bc5f3
4 changed files with 17 additions and 5 deletions

View File

@@ -22,7 +22,8 @@ public partial class MareHub
{
UID = Convert.ToString(userPair.OtherUserUID),
GID = "DIRECT",
PauseState = (userPair.IsPaused || otherUserPair.IsPaused)
PauseStateSelf = userPair.IsPaused,
PauseStateOther = otherUserPair.IsPaused
})
.Union(
(from userGroupPair in _dbContext.GroupPairs
@@ -34,15 +35,16 @@ public partial class MareHub
{
UID = Convert.ToString(otherGroupPair.GroupUserUID),
GID = Convert.ToString(otherGroupPair.GroupGID),
PauseState = (userGroupPair.IsPaused || otherGroupPair.IsPaused)
PauseStateSelf = userGroupPair.IsPaused,
PauseStateOther = otherGroupPair.IsPaused,
})
).AsNoTracking().ToListAsync().ConfigureAwait(false);
return query.GroupBy(g => g.UID, g => (g.GID, g.PauseState),
return query.GroupBy(g => g.UID, g => (g.GID, g.PauseStateSelf, g.PauseStateOther),
(key, g) => new PausedEntry
{
UID = key,
PauseStates = g.Select(p => new PauseState() { GID = string.Equals(p.GID, "DIRECT", StringComparison.Ordinal) ? null : p.GID, IsPaused = p.PauseState })
PauseStates = g.Select(p => new PauseState() { GID = string.Equals(p.GID, "DIRECT", StringComparison.Ordinal) ? null : p.GID, IsSelfPaused = p.PauseStateSelf, IsOtherPaused = p.PauseStateOther })
.ToList()
}, StringComparer.Ordinal).ToList();
}

View File

@@ -407,6 +407,7 @@ public partial class MareHub
{
if (userPair.IsDirectlyPaused != PauseInfo.NoConnection) continue;
if (userPair.IsPausedExcludingGroup(gid) is PauseInfo.Unpaused) continue;
if (userPair.IsOtherPausedForSpecificGroup(gid) is PauseInfo.Paused) continue;
}
var groupUserIdent = _clientIdentService.GetCharacterIdentForUid(groupUserPair.GroupUserUID);

View File

@@ -3,5 +3,7 @@
public record PauseState
{
public string GID { get; set; }
public bool IsPaused { get; set; }
public bool IsPaused => IsSelfPaused || IsOtherPaused;
public bool IsSelfPaused { get; set; }
public bool IsOtherPaused { get; set; }
}

View File

@@ -37,6 +37,13 @@ public record PausedEntry
}
}
public PauseInfo IsOtherPausedForSpecificGroup(string gid)
{
var state = PauseStatesWithoutDirect.SingleOrDefault(g => string.Equals(g.GID, gid, StringComparison.Ordinal));
if (state == null) return PauseInfo.NoConnection;
return state.IsOtherPaused ? PauseInfo.Paused : PauseInfo.Unpaused;
}
public PauseInfo IsPausedForSpecificGroup(string gid)
{
var state = PauseStatesWithoutDirect.SingleOrDefault(g => string.Equals(g.GID, gid, StringComparison.Ordinal));