Skip to content

Commit

Permalink
feat: sort string in list
Browse files Browse the repository at this point in the history
  • Loading branch information
Yazawazi committed Dec 23, 2023
1 parent 63eb95d commit 1b667b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
6 changes: 1 addition & 5 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import MuiAppBar, { AppBarProps as MuiAppBarProps } from "@mui/material/AppBar";
import MuiPaper, { PaperProps as MuiPaperProps } from "@mui/material/Paper";
import HistoryDialog from "./components/History/HistoryDialog";
import HistoryList from "./components/History/HistoryList";
import MarkdownDiv from "./components/Common/MarkdownDiv";
import InlineBox from "./components/Common/InlineBox";
import useFunixHistory from "./shared/useFunixHistory";

Expand Down Expand Up @@ -450,10 +449,7 @@ const App = () => {
{theme?.direction === "ltr" ? <ArrowBack /> : <ArrowForward />}
</IconButton>
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
<MarkdownDiv
markdown={selectedFunction?.name || "Funix"}
isRenderInline={true}
/>
{selectedFunction?.name || "Funix"}
</Typography>
{selectedFunction && selectedFunction.secret && (
<IconButton
Expand Down
37 changes: 15 additions & 22 deletions frontend/src/components/FunixFunctionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useAtom } from "jotai";
import { FunctionPreview, getList, objArraySort } from "../shared";
import { useNavigate, useLocation } from "react-router-dom";
import { ExpandLess, ExpandMore } from "@mui/icons-material";
import MarkdownDiv from "./Common/MarkdownDiv";

export type FunctionListProps = {
backend: URL;
Expand Down Expand Up @@ -215,25 +214,19 @@ const FunixFunctionList: React.FC<FunctionListProps> = ({ backend }) => {
if (!isTree) {
return (
<FunixList functionLength={state.length}>
{state.map((functionPreview) => (
<ListItemButton
onClick={() => {
changeRadioGroupValueById(functionPreview.id);
}}
key={functionPreview.name}
selected={radioGroupValue === functionPreview.path}
>
<ListItemText
primary={
<MarkdownDiv
markdown={functionPreview.name}
isRenderInline={true}
/>
}
disableTypography
/>
</ListItemButton>
))}
{state
.sort((a, b) => a.name.localeCompare(b.name))
.map((functionPreview) => (
<ListItemButton
onClick={() => {
changeRadioGroupValueById(functionPreview.id);
}}
key={functionPreview.name}
selected={radioGroupValue === functionPreview.path}
>
<ListItemText primary={functionPreview.name} disableTypography />
</ListItemButton>
))}
</FunixList>
);
}
Expand Down Expand Up @@ -265,7 +258,7 @@ const FunixFunctionList: React.FC<FunctionListProps> = ({ backend }) => {
}}
>
<ListItemText
primary={<MarkdownDiv markdown={name} isRenderInline={true} />}
primary={name}
sx={{
wordWrap: "break-word",
}}
Expand Down Expand Up @@ -299,7 +292,7 @@ const FunixFunctionList: React.FC<FunctionListProps> = ({ backend }) => {
}}
>
<ListItemText
primary={<MarkdownDiv markdown={k} isRenderInline={true} />}
primary={k}
sx={{
wordWrap: "break-word",
}}
Expand Down

0 comments on commit 1b667b2

Please sign in to comment.