1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

Update recently used view (#6487)

* improve recently used item list ui

* update view in recently used from repo list to folder list
This commit is contained in:
Aries
2024-08-05 16:08:05 +08:00
committed by GitHub
parent 093d8b180a
commit 3747b8acfc
5 changed files with 71 additions and 18 deletions

View File

@@ -715,16 +715,16 @@ class LibContentView extends React.Component {
});
};
updateRecentlyUsedRepos = (destRepo) => {
const recentlyUsed = JSON.parse(localStorage.getItem('recently-used-repos')) || [];
const updatedRecentlyUsed = [destRepo, ...recentlyUsed.filter(repo => repo.repo_id !== destRepo.repo_id)];
updateRecentlyUsedRepos = (destPath) => {
const recentlyUsed = JSON.parse(localStorage.getItem('recently-used-list')) || [];
const updatedRecentlyUsed = [destPath, ...recentlyUsed.filter(path => path !== destPath)];
const seen = new Set();
const filteredRecentlyUsed = updatedRecentlyUsed.filter(repo => {
if (seen.has(repo.repo_id)) {
const filteredRecentlyUsed = updatedRecentlyUsed.filter(path => {
if (seen.has(path)) {
return false;
} else {
seen.add(repo.repo_id);
seen.add(path);
return true;
}
});
@@ -733,7 +733,7 @@ class LibContentView extends React.Component {
updatedRecentlyUsed.pop(); // Limit to 10 recent directories
}
localStorage.setItem('recently-used-repos', JSON.stringify(filteredRecentlyUsed));
localStorage.setItem('recently-used-list', JSON.stringify(filteredRecentlyUsed));
};
// toolbar operations
@@ -775,7 +775,7 @@ class LibContentView extends React.Component {
toaster.success(message);
}
this.updateRecentlyUsedRepos(destRepo);
this.updateRecentlyUsedRepos(destDirentPath);
}).catch((error) => {
if (!error.response.data.lib_need_decrypt) {
@@ -1247,7 +1247,7 @@ class LibContentView extends React.Component {
toaster.success(message);
}
this.updateRecentlyUsedRepos(destRepo);
this.updateRecentlyUsedRepos(moveToDirentPath);
}).catch((error) => {
if (!error.response.data.lib_need_decrypt) {