Skip to content

Commit 600a273

Browse files
committed
feat: change favicon when conversation icon is set
1 parent 4eefad3 commit 600a273

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/components/header/ConversationHeaderInfo.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Show, createEffect } from 'solid-js'
1+
import { Show } from 'solid-js'
22
import { useStore } from '@nanostores/solid'
33
import { conversationMap, currentConversationId } from '@/stores/conversation'
44
import { useI18n } from '@/hooks'
@@ -11,8 +11,6 @@ export default () => {
1111
return $conversationMap()[$currentConversationId()]
1212
}
1313

14-
createEffect(() => { document.title = currentConversation() ? `Anse • ${(currentConversation().name || t('conversations.untitled'))}` : 'Anse' })
15-
1614
return (
1715
<div class="fi gap-1 max-w-40vw px-2 overflow-hidden text-sm">
1816
<Show when={currentConversation()}>

src/components/main/Conversation.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import { Match, Switch } from 'solid-js'
1+
import { Match, Switch, createEffect } from 'solid-js'
22
import { useStore } from '@nanostores/solid'
33
import { conversationMap, currentConversationId } from '@/stores/conversation'
44
import { conversationMessagesMap } from '@/stores/messages'
55
import { loadingStateMap, streamsMap } from '@/stores/streams'
66
import { getBotMetaById } from '@/stores/provider'
7+
import { useI18n } from '@/hooks'
78
import ConversationEmpty from './ConversationEmpty'
89
import Welcome from './Welcome'
910
import Continuous from './Continuous'
1011
import Single from './Single'
1112
import Image from './Image'
1213

1314
export default () => {
15+
const { t } = useI18n()
1416
const $conversationMap = useStore(conversationMap)
1517
const $conversationMessagesMap = useStore(conversationMessagesMap)
1618
const $currentConversationId = useStore(currentConversationId)
@@ -26,8 +28,18 @@ export default () => {
2628
const currentConversationMessages = () => {
2729
return $conversationMessagesMap()[$currentConversationId()] || []
2830
}
29-
const isStreaming = () => !!$streamsMap()[$currentConversationId()]
30-
const isLoading = () => !!$loadingStateMap()[$currentConversationId()]
31+
// const isStreaming = () => !!$streamsMap()[$currentConversationId()]
32+
// const isLoading = () => !!$loadingStateMap()[$currentConversationId()]
33+
34+
createEffect(() => {
35+
const conversation = currentConversation()
36+
document.title = conversation ? `${(conversation.name || t('conversations.untitled'))} • Anse` : 'Anse'
37+
const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement
38+
if (link) {
39+
const conversationIcon = conversation?.icon ? `data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>${conversation.icon}</text></svg>` : null
40+
link.setAttribute('href', conversationIcon || '/logo.svg')
41+
}
42+
})
3143

3244
return (
3345
<Switch

0 commit comments

Comments
 (0)