Skip to content

Commit

Permalink
Merge pull request #236 from amosproj/bugfix-chat-save-after-multiple…
Browse files Browse the repository at this point in the history
…-LLM

bugfix-chat-save-after-multiple-LLM
  • Loading branch information
manikg08 authored Jul 2, 2024
2 parents f466c22 + 34f04a2 commit 151ab85
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/frontend/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export function Header(props: DrawerHeaderProps) {
const { activeLLMs, toggleLLM } = useLLMs(activeChatId || 'default');
const { chat, status, error } = useGetChat(activeChatId);

// Determine if the button should be disabled
const isButtonDisabled = chat === undefined;


useEffect(() => {
const requestPermissions = async () => {
if (Platform.OS === 'android') {
Expand Down Expand Up @@ -54,15 +58,17 @@ export function Header(props: DrawerHeaderProps) {
timeZoneName: 'short'
}).format(createdAtDate);

const metadata = `Title: ${
const metadata = `title: ${
chat.title
}\nCreated: ${formattedCreatedAt}\nModels: ${chat.model.toString()}\n\n`;
}\ncreated: ${formattedCreatedAt}\nmodels: ${chat.model.toString()}\n\n\n`;

const formattedChatContent = chat.conversation
.map((line, index) => {
return index % 2 === 0 ? `Q: '${line}'` : `A: '${line}'\n`;
})
.join('\n');
.map((line) => {
return Object.entries(line)
.map(([key, value]) => `${key}: '${value}'`)
.join('\n');
})
.join('\n\n');

const now = new Date();
const year = now.getFullYear();
Expand Down Expand Up @@ -105,8 +111,8 @@ export function Header(props: DrawerHeaderProps) {
</View>
<View style={{ flexDirection: 'row' }}>
<DropdownMenu />
<Pressable onPress={handleAction} style={Style.actionButton}>
<IconButton icon='save' size={24} iconColor={colors.primary} />
<Pressable onPress={handleAction} style={Style.actionButton} disabled={isButtonDisabled} >
<IconButton icon='save' size={24} iconColor={colors.primary} disabled={isButtonDisabled} />
</Pressable>
</View>
</Surface>
Expand Down

0 comments on commit 151ab85

Please sign in to comment.