mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
fix move to another repo failed (#6496)
This commit is contained in:
@@ -523,7 +523,6 @@ class FileChooser extends React.Component {
|
||||
<div className="list-view">
|
||||
<RecentlyUsedListView
|
||||
recentlyUsedList={recentlyUsedList}
|
||||
selectedRepo={selectedRepo}
|
||||
onDirentItemClick={this.onDirentItemClick}
|
||||
/>
|
||||
</div>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
|
||||
const RecentlyUsedListItem = ({ path, isSelected, onItemClick }) => {
|
||||
const title = path.split('/').pop();
|
||||
const RecentlyUsedListItem = ({ item, isSelected, onItemClick }) => {
|
||||
const title = item.path.split('/').pop();
|
||||
|
||||
const handleItemClick = () => {
|
||||
onItemClick(path);
|
||||
onItemClick(item.repo, item.path);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@@ -1,22 +1,22 @@
|
||||
import React, { useState } from 'react';
|
||||
import RecentlyUsedListItem from './recently-used-list-item';
|
||||
|
||||
const RecentlyUsedListView = ({ recentlyUsedList, selectedRepo, onDirentItemClick }) => {
|
||||
const RecentlyUsedListView = ({ recentlyUsedList, onDirentItemClick }) => {
|
||||
const [selectedItem, setSelectedItem] = useState(null);
|
||||
|
||||
const onItemClick = (path) => {
|
||||
const onItemClick = (repo, path) => {
|
||||
setSelectedItem(path);
|
||||
onDirentItemClick(selectedRepo, path);
|
||||
onDirentItemClick(repo, path);
|
||||
};
|
||||
|
||||
return (
|
||||
<ul className="list-view-content file-chooser-item" >
|
||||
{recentlyUsedList.length > 0 && recentlyUsedList.map((path, index) => {
|
||||
{recentlyUsedList.length > 0 && recentlyUsedList.map((item, index) => {
|
||||
return (
|
||||
<RecentlyUsedListItem
|
||||
key={index}
|
||||
path={path}
|
||||
isSelected={selectedItem === path}
|
||||
item={item}
|
||||
isSelected={selectedItem === item.path}
|
||||
onItemClick={onItemClick}
|
||||
/>
|
||||
);
|
||||
|
@@ -715,16 +715,16 @@ class LibContentView extends React.Component {
|
||||
});
|
||||
};
|
||||
|
||||
updateRecentlyUsedRepos = (destPath) => {
|
||||
updateRecentlyUsedRepos = (repo, destPath) => {
|
||||
const recentlyUsed = JSON.parse(localStorage.getItem('recently-used-list')) || [];
|
||||
const updatedRecentlyUsed = [destPath, ...recentlyUsed.filter(path => path !== destPath)];
|
||||
const updatedRecentlyUsed = [{ repo: repo, path: destPath }, ...recentlyUsed.filter(item => item.path !== destPath)];
|
||||
|
||||
const seen = new Set();
|
||||
const filteredRecentlyUsed = updatedRecentlyUsed.filter(path => {
|
||||
if (seen.has(path)) {
|
||||
const filteredRecentlyUsed = updatedRecentlyUsed.filter(item => {
|
||||
if (seen.has(item.path)) {
|
||||
return false;
|
||||
} else {
|
||||
seen.add(path);
|
||||
seen.add(item.path);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -775,7 +775,7 @@ class LibContentView extends React.Component {
|
||||
toaster.success(message);
|
||||
}
|
||||
|
||||
this.updateRecentlyUsedRepos(destDirentPath);
|
||||
this.updateRecentlyUsedRepos(destRepo, destDirentPath);
|
||||
|
||||
}).catch((error) => {
|
||||
if (!error.response.data.lib_need_decrypt) {
|
||||
@@ -1247,7 +1247,7 @@ class LibContentView extends React.Component {
|
||||
toaster.success(message);
|
||||
}
|
||||
|
||||
this.updateRecentlyUsedRepos(moveToDirentPath);
|
||||
this.updateRecentlyUsedRepos(destRepo, moveToDirentPath);
|
||||
|
||||
}).catch((error) => {
|
||||
if (!error.response.data.lib_need_decrypt) {
|
||||
|
Reference in New Issue
Block a user