mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 17:47:30 +13:00
Fix browser race condition
This commit is contained in:
parent
20b96d7f25
commit
73e351d5ef
2 changed files with 5 additions and 3 deletions
|
@ -306,22 +306,21 @@ public final class OpenFileSystemModel {
|
||||||
this.fileSystem = fs;
|
this.fileSystem = fs;
|
||||||
this.local =
|
this.local =
|
||||||
fs.getShell().map(shellControl -> shellControl.isLocal()).orElse(false);
|
fs.getShell().map(shellControl -> shellControl.isLocal()).orElse(false);
|
||||||
|
this.initState();
|
||||||
this.cache.init();
|
this.cache.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initWithGivenDirectory(String dir) throws Exception {
|
public void initWithGivenDirectory(String dir) throws Exception {
|
||||||
initState();
|
|
||||||
cdSyncWithoutCheck(dir);
|
cdSyncWithoutCheck(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initWithDefaultDirectory() throws Exception {
|
public void initWithDefaultDirectory() throws Exception {
|
||||||
initState();
|
|
||||||
savedState.cd(null);
|
savedState.cd(null);
|
||||||
history.updateCurrent(null);
|
history.updateCurrent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initState() {
|
void initState() {
|
||||||
this.savedState = OpenFileSystemSavedState.loadForStore(this);
|
this.savedState = OpenFileSystemSavedState.loadForStore(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,9 @@ public class OpenFileSystemSavedState {
|
||||||
.constructCollectionLikeType(List.class, RecentEntry.class);
|
.constructCollectionLikeType(List.class, RecentEntry.class);
|
||||||
List<RecentEntry> recentDirectories =
|
List<RecentEntry> recentDirectories =
|
||||||
JacksonMapper.getDefault().treeToValue(tree.remove("recentDirectories"), javaType);
|
JacksonMapper.getDefault().treeToValue(tree.remove("recentDirectories"), javaType);
|
||||||
|
if (recentDirectories == null) {
|
||||||
|
recentDirectories = List.of();
|
||||||
|
}
|
||||||
var cleaned = recentDirectories.stream()
|
var cleaned = recentDirectories.stream()
|
||||||
.map(recentEntry -> new RecentEntry(FileNames.toDirectory(recentEntry.directory), recentEntry.time))
|
.map(recentEntry -> new RecentEntry(FileNames.toDirectory(recentEntry.directory), recentEntry.time))
|
||||||
.filter(distinctBy(recentEntry -> recentEntry.getDirectory()))
|
.filter(distinctBy(recentEntry -> recentEntry.getDirectory()))
|
||||||
|
|
Loading…
Reference in a new issue