Skip to content

Commit

Permalink
feat: render empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentdchan committed Sep 17, 2022
1 parent e85e9fd commit 14af990
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/renderer/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "@fortawesome/free-solid-svg-icons";
import IconImage from "./images/icons.png";
import { listenWindow } from "blocky-common/es/dom";
import { isUndefined } from "lodash-es";
import "./app.scss";
import "./welcome.scss";

Expand Down Expand Up @@ -158,10 +159,15 @@ export function useSelectable(
}

const FileList = memo(() => {
const [recentList, setRecentList] = useState<RecentNotebook[]>([]);
const [recentList, setRecentList] = useState<RecentNotebook[] | undefined>(
undefined,
);
const [selectedIndex, setSelectedIndex] = useSelectable({
length: recentList.length,
length: recentList?.length ?? 0,
onSelect: async (index: number) => {
if (isUndefined(recentList)) {
return;
}
const item = recentList[index];
await openNotebook.request({
path: item.localPath!,
Expand Down Expand Up @@ -189,6 +195,9 @@ const FileList = memo(() => {
flags: OpenNotebookFlag.OpenPath,
});
};
if (isUndefined(recentList)) {
return <div className="cuby-file-list"></div>;
}
if (recentList.length === 0) {
return (
<div className="cuby-file-list">
Expand Down

0 comments on commit 14af990

Please sign in to comment.