Run restore action staggered

This commit is contained in:
crschnick 2024-01-03 14:22:18 +00:00
parent ab8b6d449e
commit 0754e79970
2 changed files with 8 additions and 4 deletions

View file

@ -51,12 +51,16 @@ public class BrowserModel {
}
public void restoreState(BrowserSavedState state) {
state.getEntries().forEach(e -> {
restoreState(e, null);
ThreadHelper.runAsync(() -> {
state.getEntries().forEach(e -> {
restoreStateAsync(e, null);
});
// Don't try to run everything in parallel as that can be taxing
ThreadHelper.sleep(1000);
});
}
public void restoreState(BrowserSavedState.Entry e, BooleanProperty busy) {
public void restoreStateAsync(BrowserSavedState.Entry e, BooleanProperty busy) {
var storageEntry = DataStorage.get().getStoreEntryIfPresent(e.getUuid());
storageEntry.ifPresent(entry -> {
openFileSystemAsync(entry.ref(), model -> e.getPath(), busy);

View file

@ -88,7 +88,7 @@ public class BrowserWelcomeComp extends SimpleComp {
var disable = new SimpleBooleanProperty();
return new ButtonComp(null, content, () -> {
ThreadHelper.runAsync(() -> {
model.restoreState(e, disable);
model.restoreStateAsync(e, disable);
});
}).accessibleText(DataStorage.get().getStoreDisplayName(entry.get())).disable(disable).styleClass("color-listBox").apply(struc -> struc.get().setMaxWidth(2000)).grow(true, false);
}).apply(struc -> {