Skip to content

Commit

Permalink
Fix broken chat
Browse files Browse the repository at this point in the history
The chat could be broken since the write item return value "fix" from 537f308

Also remove our own location from the connection count, since obviously it's not part of it.
  • Loading branch information
zapek committed Jan 5, 2025
1 parent b0d5bee commit 60bae18
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/io/xeres/app/application/Startup.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void onApplicationEvent(LocationReadyEvent ignoredEvent)
try (var ignored = new DatabaseSession(databaseSessionManager))
{
syncAutoStart();
statusNotificationService.setTotalUsers((int) locationService.getAllLocations().stream().filter(location -> !location.isOwn()).count());
statusNotificationService.setTotalUsers((int) locationService.countLocations());
networkService.start();
}
MinimalUserInterface.setShell(shellService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void setCurrentUsersCount(int value)

public void setTotalUsers(int value)
{
totalUsers = value;
totalUsers = value - 1; // We remove our own location
sendNotification(createNotification());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ private boolean bounce(PeerConnection peerConnection, ChatRoomBounce bounce)
if (peerConnection == null || !Objects.equals(location, peerConnection.getLocation()))
{
var status = peerConnectionManager.writeItem(location, bounce.clone(), this); // Netty frees sent items so we need to clone
if (!status.isSuccess())
if (status.isDone() && !status.isSuccess())
{
iterator.remove(); // Failed to write, it means the location disconnected, so we need to remove it from our participating locations
}
Expand Down

0 comments on commit 60bae18

Please sign in to comment.