Skip to content

Commit

Permalink
add error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
samlhuillier committed Nov 30, 2023
1 parent 77626d0 commit c4518a5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
16 changes: 8 additions & 8 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import { FileInfoTree } from "./Files/Types";
import { registerDBSessionHandlers } from "./database/dbSessionHandlers";

const store = new Store<StoreSchema>();
// const user = store.get("user");
const user = store.get("user");

// // Check if 'user' and 'directory' exist before attempting to delete
// if (user && typeof user === "object" && "directory" in user) {
// // Delete the 'directory' property
// delete user.directory;
// Check if 'user' and 'directory' exist before attempting to delete
if (user && typeof user === "object" && "directory" in user) {
// Delete the 'directory' property
delete user.directory;

// // Save the updated 'user' object back to the store
// store.set("user", user);
// }
// Save the updated 'user' object back to the store
store.set("user", user);
}

process.env.DIST_ELECTRON = join(__dirname, "../");
process.env.DIST = join(process.env.DIST_ELECTRON, "../dist");
Expand Down
2 changes: 1 addition & 1 deletion src/components/File/NewNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const NewNoteComponent: React.FC<NewNoteComponentProps> = ({
placeholder="Note Name"
/>
<Button
className="bg-slate-700 mt-3 border-none h-10 hover:bg-slate-900 cursor-pointer w-[80px] text-center pt-0 pb-0 pr-2 pl-2"
className="bg-slate-700 mt-3 mb-2 border-none h-10 hover:bg-slate-900 cursor-pointer w-[80px] text-center pt-0 pb-0 pr-2 pl-2"
onClick={sendNewNoteMsg}
>
Create
Expand Down
17 changes: 8 additions & 9 deletions src/components/Settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DirectoryPicker: React.FC<Props> = ({ onDirectorySelected }) => {
const [isModalOpen, setIsModalOpen] = useState(true);
const [openAIKey, setOpenAIKey] = useState("");
const [userDirectory, setUserDirectory] = useState("");

const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
const key = window.electronStore.getOpenAIAPIKey() || ""; // Fallback to empty string if undefined
setOpenAIKey(key);
Expand All @@ -23,6 +23,8 @@ const DirectoryPicker: React.FC<Props> = ({ onDirectorySelected }) => {
if (userDirectory) {
window.electronStore.setUserDirectory(userDirectory);
onDirectorySelected(userDirectory);
} else {
setErrorMsg("Please select a directory.");
}
};

Expand Down Expand Up @@ -74,15 +76,15 @@ const DirectoryPicker: React.FC<Props> = ({ onDirectorySelected }) => {
className="block w-[470px] px-3 py-2 mr-2 border border-gray-300 rounded-md bg-gray-200 cursor-not-allowed"
value={"BAAI/bge-base-en-v1.5"}
disabled
placeholder="Note Name"
placeholder="Embedding Model Name"
/>
<h4 className="font-semibold mb-2 text-white">LLM</h4>
<input
type="text"
className="block w-[470px] px-3 py-2 border border-gray-300 rounded-md bg-gray-200 cursor-not-allowed"
value={"GPT-3.5-turbo"}
disabled
placeholder="Note Name"
placeholder="LLM Model Name"
/>
<p className="mt-2 text-xs text-gray-100">
*Models are currently hardcoded (custom models are coming soon).
Expand All @@ -94,19 +96,16 @@ const DirectoryPicker: React.FC<Props> = ({ onDirectorySelected }) => {
value={openAIKey}
onChange={(e) => setOpenAIKey(e.target.value)}
onKeyDown={handleKeyPress}
placeholder="Note Name"
placeholder="Open AI API Key"
/>

<Button
className="bg-slate-700 mt-6 mb-2 border-none h-10 hover:bg-slate-900 cursor-pointer w-[80px] text-center pt-0 pb-0 pr-2 pl-2"
className="bg-slate-700 mt-6 border-none h-10 hover:bg-slate-900 cursor-pointer w-[80px] text-center pt-0 pb-0 pr-2 pl-2"
onClick={handleNext}
>
Next
</Button>
{/* <p className="text-xs text-white">
*Models are currently hardcoded. Custom models are coming very soon
:)
</p> */}
{errorMsg && <p className="text-xs text-red-500">{errorMsg}</p>}
</div>
</div>
</Modal>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const SettingsModal: React.FC<ModalProps> = ({ isOpen, onClose }) => {
className="block w-full px-3 py-2 border border-gray-300 rounded-md bg-gray-200 cursor-not-allowed"
value={"BAAI/bge-base-en-v1.5"}
disabled
placeholder="Note Name"
placeholder="Embedding Model"
/>
<h4 className="font-semibold mb-2 text-white">LLM</h4>
<input
type="text"
className="block w-full px-3 py-2 border border-gray-300 rounded-md bg-gray-200 cursor-not-allowed"
value={"GPT-3.5-turbo"}
disabled
placeholder="Note Name"
placeholder="LLM Model"
/>
<h4 className="font-semibold mb-2 text-white">Open AI Key</h4>
<input
Expand All @@ -54,7 +54,7 @@ const SettingsModal: React.FC<ModalProps> = ({ isOpen, onClose }) => {
value={openAIKey}
onChange={(e) => setOpenAIKey(e.target.value)}
onKeyDown={handleKeyPress}
placeholder="Note Name"
placeholder="Open AI API Key"
/>

<Button
Expand Down

0 comments on commit c4518a5

Please sign in to comment.