Update cached data in RemoteRecorder so that views update faster
This commit is contained in:
parent
6e5d706f65
commit
0d02a6cf9c
|
@ -100,6 +100,7 @@ public class RecordLaterTab extends AbstractRecordedModelsTab implements TabSele
|
||||||
filteredModels.clear();
|
filteredModels.clear();
|
||||||
filter(filter.getText());
|
filter(filter.getText());
|
||||||
table.sort();
|
table.sort();
|
||||||
|
table.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOrUpdateModels(List<JavaFxModel> updatedModels) {
|
private void addOrUpdateModels(List<JavaFxModel> updatedModels) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ public abstract class AbstractModelTask {
|
||||||
|
|
||||||
public CompletableFuture<Model> executeSync(Model model) {
|
public CompletableFuture<Model> executeSync(Model model) {
|
||||||
try {
|
try {
|
||||||
org.slf4j.LoggerFactory.getLogger(getClass()).debug("Executing concrete task for {} - suspended:{}", model, model.isSuspended());
|
|
||||||
concreteTask.accept(model);
|
concreteTask.accept(model);
|
||||||
return CompletableFuture.completedFuture(model);
|
return CompletableFuture.completedFuture(model);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -103,11 +103,19 @@ public class RemoteRecorder implements Recorder {
|
||||||
LOG.trace("Model until: {}", model.getRecordUntil().equals(Instant.ofEpochMilli(Model.RECORD_INDEFINITELY)) ? "no limit" : model.getRecordUntil());
|
LOG.trace("Model until: {}", model.getRecordUntil().equals(Instant.ofEpochMilli(Model.RECORD_INDEFINITELY)) ? "no limit" : model.getRecordUntil());
|
||||||
LOG.trace("Model after: {}", model.getRecordUntilSubsequentAction());
|
LOG.trace("Model after: {}", model.getRecordUntilSubsequentAction());
|
||||||
sendRequest("start", model);
|
sendRequest("start", model);
|
||||||
|
findModel(model).ifPresent(cachedModel -> {
|
||||||
|
cachedModel.setSuspended(model.isSuspended());
|
||||||
|
cachedModel.setMarkedForLaterRecording(model.isMarkedForLaterRecording());
|
||||||
|
cachedModel.setRecordUntil(model.getRecordUntil());
|
||||||
|
cachedModel.setRecordUntilSubsequentAction(model.getRecordUntilSubsequentAction());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopRecording(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
public void stopRecording(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
|
||||||
sendRequest("stop", model);
|
sendRequest("stop", model);
|
||||||
|
models.remove(model);
|
||||||
|
onlineModels.remove(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,13 +155,6 @@ public class RemoteRecorder implements Recorder {
|
||||||
if (!resp.status.equals(SUCCESS)) {
|
if (!resp.status.equals(SUCCESS)) {
|
||||||
throw new IOException("Server returned error " + resp.status + " " + resp.msg);
|
throw new IOException("Server returned error " + resp.status + " " + resp.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("start".equals(action)) {
|
|
||||||
models.add(model);
|
|
||||||
} else if ("stop".equals(action)) {
|
|
||||||
models.remove(model);
|
|
||||||
onlineModels.remove(model);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new HttpException(response.code(), response.message());
|
throw new HttpException(response.code(), response.message());
|
||||||
}
|
}
|
||||||
|
@ -733,8 +734,10 @@ public class RemoteRecorder implements Recorder {
|
||||||
int index = models.indexOf(model);
|
int index = models.indexOf(model);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
Model m = models.get(index);
|
Model m = models.get(index);
|
||||||
|
if (m.isMarkedForLaterRecording() && !mark) {
|
||||||
|
models.remove(m);
|
||||||
|
}
|
||||||
m.setMarkedForLaterRecording(mark);
|
m.setMarkedForLaterRecording(mark);
|
||||||
models.remove(index);
|
|
||||||
} else {
|
} else {
|
||||||
models.add(model);
|
models.add(model);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue