Skip to content

Commit

Permalink
fix move to another repo failed (#6496)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aries-0331 authored Aug 6, 2024
1 parent a92ebc9 commit cfed276
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion frontend/src/components/file-chooser/file-chooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ class FileChooser extends React.Component {
<div className="list-view">
<RecentlyUsedListView
recentlyUsedList={recentlyUsedList}
selectedRepo={selectedRepo}
onDirentItemClick={this.onDirentItemClick}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/file-chooser/recently-used-list-view.js
Original file line number Diff line number Diff line change
@@ -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}
/>
);
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cfed276

Please sign in to comment.