Skip to content

Commit

Permalink
code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Aug 1, 2023
1 parent 3b11ee1 commit 4af6bab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ export class LimitLength {

const elementLength = element.currentTarget.textContent.trim().length;

const anyKeyRegex = new RegExp(/^.?$/);

if (
elementLength < this.maxlength ||
window.getSelection()?.type === "Range" ||
(element.key === "x" && element.ctrlKey) ||
(element.key === "x" && element.metaKey) ||
!element.key.match(/^.?$/)
!anyKeyRegex.exec(element.key)
)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ const ArchiveSidebarSelectionList: React.FunctionComponent<IDetailViewSidebarSel
{select
? select.map(
(
item,
index // item is filename
item // item is filename
) => (
<li key={index}>
<li key={item}>
<span
onClick={() => toggleSelection(item)}
className="close"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ interface ItemListProps {
isLoading?: boolean;
callback?(path: string): void;
}

function GetBoxClass(item: IFileIndexItem): string {
if (item.isDirectory) {
return "box isDirectory-true";
} else if (
item.status === IExifStatus.Ok ||
item.status === IExifStatus.Default
) {
return "box isDirectory-false";
} else {
return "box isDirectory-false error";
}
}

/**
* A list with links to the items
*/
Expand Down Expand Up @@ -47,14 +61,7 @@ const ItemTextListView: React.FunctionComponent<ItemListProps> = (props) => {
<ul>
{props.fileIndexItems.map((item, index) => (
<li
className={
item.isDirectory
? "box isDirectory-true"
: item.status === IExifStatus.Ok ||
item.status === IExifStatus.Default
? "box isDirectory-false"
: "box isDirectory-false error"
}
className={GetBoxClass(item)}
key={item.filePath + item.lastEdited}
>
{item.isDirectory ? (
Expand Down

0 comments on commit 4af6bab

Please sign in to comment.