SEBSERV-276 fixed done reload page on missing change

This commit is contained in:
anhefti 2022-02-09 14:12:55 +01:00
parent a55cc57cb5
commit d26cc8930e

View file

@ -69,6 +69,7 @@ public class ClientConnectionDetails {
private ClientConnectionData connectionData = null;
private boolean statusChanged = true;
private boolean missingChanged = true;
private long startTime = -1;
private Consumer<ClientConnectionData> statusChangeListener = null;
@ -143,9 +144,9 @@ public class ClientConnectionDetails {
if (this.connectionData != null && connectionData != null) {
this.statusChanged =
this.connectionData.clientConnection.status != connectionData.clientConnection.status ||
BooleanUtils.toBoolean(this.connectionData.missingPing) != BooleanUtils
.toBoolean(connectionData.missingPing);
this.connectionData.clientConnection.status != connectionData.clientConnection.status;
this.missingChanged = BooleanUtils.toBoolean(this.connectionData.missingPing) != BooleanUtils
.toBoolean(connectionData.missingPing);
}
this.connectionData = connectionData;
if (this.startTime < 0) {
@ -157,6 +158,10 @@ public class ClientConnectionDetails {
final Supplier<EntityTable<ClientNotification>> notificationTableSupplier,
final PageContext pageContext) {
if (this.connectionData == null) {
return;
}
// Note: This is to update the whole page (by reload) only when the status has changed
// while this page was open. This prevent constant page reloads.
if (this.statusChanged && System.currentTimeMillis() - this.startTime > Constants.SECOND_IN_MILLIS) {
@ -164,10 +169,6 @@ public class ClientConnectionDetails {
return;
}
if (this.connectionData == null) {
return;
}
final Form form = this.formHandle.getForm();
form.setFieldValue(
Domain.CLIENT_CONNECTION.ATTR_EXAM_USER_SESSION_ID,
@ -177,7 +178,7 @@ public class ClientConnectionDetails {
ClientConnection.ATTR_INFO,
this.connectionData.clientConnection.info);
if (this.statusChanged) {
if (this.missingChanged) {
// update status
form.setFieldValue(
Domain.CLIENT_CONNECTION.ATTR_STATUS,