mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 20:17:22 +01:00
implement callbacks
This commit is contained in:
parent
ac6c46390c
commit
d2bb4e01a4
3 changed files with 32 additions and 2 deletions
2
MareAPI
2
MareAPI
|
|
@ -1 +1 @@
|
||||||
Subproject commit 57a7ab82625ca350bce0442c60f457e5e5e172c3
|
Subproject commit 008f88674347b5230b860366017eb3ec157b2090
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MareSynchronos.API;
|
using MareSynchronos.API;
|
||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,40 @@ public partial class ApiController
|
||||||
|
|
||||||
private void GroupPairChangedCallback(GroupPairDto dto)
|
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)
|
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