Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: listing result could be returned after chdir
  • Loading branch information
ihexxa committed Jan 13, 2026
commit 6ac9e6c8cf4bef95677c6e709f15dd3c08fc44de
18 changes: 15 additions & 3 deletions src/client/web/src/components/state_updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,28 @@ export class Updater {
};

refreshFiles = async (): Promise<string> => {
const status = await this.setItems(this.props.filesInfo.dirPath);
const status = await this.setItems(this.props.filesInfo.dirPath, true);
if (status !== "") {
return status;
}
};

setItems = async (dirParts: List<string>): Promise<string> => {
setItems = async (
dirParts: List<string>,
isRefreshing?: boolean
): Promise<string> => {
const dirPath = dirParts.join("/");
const listResp = await this.filesClient.list(dirPath);

// The listing result could be returned after user has been gone to another directory
// isStillInThePath compares the listing one with the current one
// TODO: in the long-term listing result should be ordered and canceled
const isStillInThePath = dirPath === this.props.filesInfo.dirPath.join("/");
if (isRefreshing && !isStillInThePath) {
// ignore the result
return "";
}

if (listResp.status === 200) {
this.props.filesInfo.dirPath = dirParts;
this.props.filesInfo.items = List<MetadataResp>(listResp.data.metadatas);
Expand Down Expand Up @@ -1037,7 +1049,7 @@ export class Updater {
reindex = async (): Promise<string> => {
const resp = await this.filesClient.reindex();
return resp.status === 200 ? "" : errServer;
}
};

hasResult = (): boolean => {
return this.props.filesInfo.searchResults.size > 0;
Expand Down
Loading