Fix Contacts Status' Not Updating
Implement Room User Count SQL SCHEMA CHANGE `ALTER TABLE Rooms ADD COLUMN UserCount INT(32) NOT NULL;`
This commit is contained in:
parent
2d5cd25a55
commit
110f8c77dd
@ -113,6 +113,7 @@ namespace qtc_api.Hubs
|
||||
if (res != null && res.Success && res.Data != null)
|
||||
{
|
||||
await Clients.All.SendAsync("RefreshUserLists");
|
||||
await Clients.All.SendAsync("RefreshContactsList");
|
||||
Log($"Status Was Set To {res.Data.Status} On User {user.Username}");
|
||||
}
|
||||
else
|
||||
@ -134,7 +135,14 @@ namespace qtc_api.Hubs
|
||||
Log($"User {user.Username} Has Joined {room.Name}");
|
||||
|
||||
user.CurrentRoomId = room.Id;
|
||||
|
||||
ServiceResponse<Room> dbRoomRes = await _roomService.GetRoom(room.Id);
|
||||
Room? dbRoom = dbRoomRes?.Data;
|
||||
|
||||
if(dbRoom != null) dbRoom.UserCount += 1;
|
||||
|
||||
await _dataContext.SaveChangesAsync();
|
||||
await Clients.All.SendAsync("RefreshRoomList");
|
||||
}
|
||||
|
||||
[HubMethodName("JoinRoomGuest")]
|
||||
@ -148,6 +156,11 @@ namespace qtc_api.Hubs
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, room.Data.Id);
|
||||
|
||||
await Clients.Group(room.Data.Id).SendAsync("GuestJoin", username);
|
||||
|
||||
room.Data.UserCount += 1;
|
||||
await _dataContext.SaveChangesAsync();
|
||||
|
||||
await Clients.All.SendAsync("RefreshRoomList");
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +178,14 @@ namespace qtc_api.Hubs
|
||||
Log($"User {user.Username} Has Left {room.Name}");
|
||||
|
||||
user.CurrentRoomId = string.Empty;
|
||||
|
||||
ServiceResponse<Room> dbRoomRes = await _roomService.GetRoom(room.Id);
|
||||
Room? dbRoom = dbRoomRes?.Data;
|
||||
|
||||
if (dbRoom != null) dbRoom.UserCount -= 1;
|
||||
|
||||
await _dataContext.SaveChangesAsync();
|
||||
await Clients.All.SendAsync("RefreshRoomList");
|
||||
}
|
||||
|
||||
[HubMethodName("SendMessage")]
|
||||
|
||||
@ -6,5 +6,6 @@
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string CreatorId { get; set; } = string.Empty;
|
||||
public DateTime CreatedAt { get; set; } = new DateTime();
|
||||
public int UserCount { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user