Skip to content

Commit

Permalink
performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Nov 6, 2024
1 parent cbcef7d commit 611502b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/aipane/components/Aipane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const Aipane: React.FC<AipaneProps> = (props: AipaneProps): React.JSX.Element =>
{/* <HeroList message="Ask Llama" items={listItems} /> */}
<HeroProviders onChange={handleProviderChange} />
<HeroModels onChange={handleModelChange} provider={provider} />
<HeroComboPrompts onChange={handlePromptChange} />
<HeroComboPrompts onChange={handlePromptChange} standalone={!isOutlook} />
<TextInsertion getAIAnswer={handlePromptSubmit} basePrompt={""} />
</>
)}
Expand Down
13 changes: 5 additions & 8 deletions src/aipane/components/HeroComboPrompts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Dropdown, Label, makeStyles, Option, useId } from "@fluentui/react-comp
import { useState, useEffect, useCallback } from "react";
import { getPrompts, type AIPrompt } from "../AIPrompt";
import { config } from "../config";
import { isOutlookClient } from "../aipane";

interface HeroComboPromptsProps {
onChange: (selectedValue: string) => void;
standalone: boolean;
}

const useStyles = makeStyles({
Expand All @@ -29,20 +29,17 @@ const useStyles = makeStyles({
},
});

const HeroComboPrompts: React.FC<HeroComboPromptsProps> = ({ onChange }) => {
const HeroComboPrompts: React.FC<HeroComboPromptsProps> = ({ onChange, standalone }) => {
const styles = useStyles();
const inputId = useId("input");
const [selectedValue, setSelectedValue] = useState<string>(config.prompts[0].id);
const [prompts, setPrompts] = useState<AIPrompt[]>([]);
const [isOutlook, setIsOutlook] = useState<boolean>(false);
const [, setIsOutlook] = useState<boolean>(false);

// Filter out standalone prompts if the client is Outlook
// Standalone prompts should be used in standalone mode only
useEffect(() => {
isOutlookClient().then((_isOutlook) => {
setIsOutlook(_isOutlook);
setPrompts(getPrompts(!isOutlook));
});
setIsOutlook(!standalone);
setPrompts(getPrompts(standalone));
}, []);

const handleChange = useCallback(
Expand Down

0 comments on commit 611502b

Please sign in to comment.