mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 13:50:07 +00:00
fix recently used list (#7393)
* fix recently used list * fix recently used list --------- Co-authored-by: zhouwenxuan <aries@Mac.local>
This commit is contained in:
@@ -731,22 +731,18 @@ class LibContentView extends React.Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
updateRecentlyUsedRepos = (repo, destPath) => {
|
updateRecentlyUsedList = (repo, destPath) => {
|
||||||
const recentlyUsed = JSON.parse(localStorage.getItem('recently-used-list')) || [];
|
const recentlyUsed = JSON.parse(localStorage.getItem('recently-used-list')) || [];
|
||||||
const updatedRecentlyUsed = [{ repo_id: repo.repo_id, path: destPath }, ...recentlyUsed.filter(item => item.path !== destPath)];
|
const updatedRecentlyUsed = [{ repo_id: repo.repo_id, path: destPath }, ...recentlyUsed];
|
||||||
|
|
||||||
const seen = new Set();
|
const filteredRecentlyUsed = updatedRecentlyUsed.filter((item, index, self) =>
|
||||||
const filteredRecentlyUsed = updatedRecentlyUsed.filter(item => {
|
index === self.findIndex(t => (
|
||||||
if (seen.has(item.path)) {
|
t.repo_id === item.repo_id && t.path === item.path
|
||||||
return false;
|
))
|
||||||
} else {
|
);
|
||||||
seen.add(item.path);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (filteredRecentlyUsed.length > 10) {
|
if (filteredRecentlyUsed.length > 10) {
|
||||||
updatedRecentlyUsed.pop(); // Limit to 10 recent directories
|
filteredRecentlyUsed.pop(); // Limit to 10 recent directories
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem('recently-used-list', JSON.stringify(filteredRecentlyUsed));
|
localStorage.setItem('recently-used-list', JSON.stringify(filteredRecentlyUsed));
|
||||||
@@ -792,7 +788,7 @@ class LibContentView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (byDialog) {
|
if (byDialog) {
|
||||||
this.updateRecentlyUsedRepos(destRepo, destDirentPath);
|
this.updateRecentlyUsedList(destRepo, destDirentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
@@ -842,10 +838,10 @@ class LibContentView extends React.Component {
|
|||||||
// show tip message if copy to current repo
|
// show tip message if copy to current repo
|
||||||
let message = Utils.getCopySuccessfulMessage(dirNames);
|
let message = Utils.getCopySuccessfulMessage(dirNames);
|
||||||
toaster.success(message);
|
toaster.success(message);
|
||||||
|
}
|
||||||
|
|
||||||
if (byDialog) {
|
if (byDialog) {
|
||||||
this.updateRecentlyUsedRepos(destRepo, destDirentPath);
|
this.updateRecentlyUsedList(destRepo, destDirentPath);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (!error.response.data.lib_need_decrypt) {
|
if (!error.response.data.lib_need_decrypt) {
|
||||||
@@ -1277,7 +1273,7 @@ class LibContentView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (byDialog) {
|
if (byDialog) {
|
||||||
this.updateRecentlyUsedRepos(targetRepo, moveToDirentPath);
|
this.updateRecentlyUsedList(targetRepo, moveToDirentPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1323,6 +1319,9 @@ class LibContentView extends React.Component {
|
|||||||
}, () => {
|
}, () => {
|
||||||
this.getAsyncCopyMoveProgress();
|
this.getAsyncCopyMoveProgress();
|
||||||
});
|
});
|
||||||
|
if (byDialog) {
|
||||||
|
this.updateRecentlyUsedList(targetRepo, copyToDirentPath);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1340,7 +1339,7 @@ class LibContentView extends React.Component {
|
|||||||
toaster.success(message);
|
toaster.success(message);
|
||||||
|
|
||||||
if (byDialog) {
|
if (byDialog) {
|
||||||
this.updateRecentlyUsedRepos(targetRepo, copyToDirentPath);
|
this.updateRecentlyUsedList(targetRepo, copyToDirentPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user