mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 21:27:21 +01:00
implement callbacks
This commit is contained in:
parent
ac6c46390c
commit
d2bb4e01a4
3 changed files with 32 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
|
|
|||
|
|
@ -77,11 +77,40 @@ public partial class ApiController
|
|||
|
||||
private void GroupPairChangedCallback(GroupPairDto dto)
|
||||
{
|
||||
if (dto.IsRemoved.GetValueOrDefault(false))
|
||||
{
|
||||
GroupPairedClients.RemoveAll(g => g.GroupGID == dto.GroupGID && g.UserUID == dto.UserUID);
|
||||
}
|
||||
|
||||
var existingUser = GroupPairedClients.FirstOrDefault(f => f.GroupGID == dto.GroupGID && f.UserUID == dto.UserUID);
|
||||
if (existingUser == null)
|
||||
{
|
||||
GroupPairedClients.Add(dto);
|
||||
return;
|
||||
}
|
||||
|
||||
existingUser.IsPaused = dto.IsPaused ?? existingUser.IsPaused;
|
||||
existingUser.UserAlias = dto.UserAlias ?? existingUser.UserAlias;
|
||||
}
|
||||
|
||||
private void GroupChangedCallback(GroupDto dto)
|
||||
{
|
||||
if (dto.IsDeleted.GetValueOrDefault(false))
|
||||
{
|
||||
Groups.RemoveAll(g => g.GID == dto.GID);
|
||||
GroupPairedClients.RemoveAll(g => g.GroupGID == dto.GID);
|
||||
return;
|
||||
}
|
||||
|
||||
var existingGroup = Groups.FirstOrDefault(g => g.GID == dto.GID);
|
||||
if (existingGroup == null)
|
||||
{
|
||||
Groups.Add(dto);
|
||||
return;
|
||||
}
|
||||
|
||||
existingGroup.OwnedBy = dto.OwnedBy ?? existingGroup.OwnedBy;
|
||||
existingGroup.InvitesEnabled = dto.InvitesEnabled ?? existingGroup.InvitesEnabled;
|
||||
existingGroup.IsPaused = dto.IsPaused ?? existingGroup.IsPaused;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue