Skip to content

Commit

Permalink
feat: change favicon when conversation icon is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed May 24, 2023
1 parent 4eefad3 commit 600a273
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/components/header/ConversationHeaderInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Show, createEffect } from 'solid-js'
import { Show } from 'solid-js'
import { useStore } from '@nanostores/solid'
import { conversationMap, currentConversationId } from '@/stores/conversation'
import { useI18n } from '@/hooks'
Expand All @@ -11,8 +11,6 @@ export default () => {
return $conversationMap()[$currentConversationId()]
}

createEffect(() => { document.title = currentConversation() ? `Anse • ${(currentConversation().name || t('conversations.untitled'))}` : 'Anse' })

return (
<div class="fi gap-1 max-w-40vw px-2 overflow-hidden text-sm">
<Show when={currentConversation()}>
Expand Down
18 changes: 15 additions & 3 deletions src/components/main/Conversation.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { Match, Switch } from 'solid-js'
import { Match, Switch, createEffect } from 'solid-js'
import { useStore } from '@nanostores/solid'
import { conversationMap, currentConversationId } from '@/stores/conversation'
import { conversationMessagesMap } from '@/stores/messages'
import { loadingStateMap, streamsMap } from '@/stores/streams'
import { getBotMetaById } from '@/stores/provider'
import { useI18n } from '@/hooks'
import ConversationEmpty from './ConversationEmpty'
import Welcome from './Welcome'
import Continuous from './Continuous'
import Single from './Single'
import Image from './Image'

export default () => {
const { t } = useI18n()
const $conversationMap = useStore(conversationMap)
const $conversationMessagesMap = useStore(conversationMessagesMap)
const $currentConversationId = useStore(currentConversationId)
Expand All @@ -26,8 +28,18 @@ export default () => {
const currentConversationMessages = () => {
return $conversationMessagesMap()[$currentConversationId()] || []
}
const isStreaming = () => !!$streamsMap()[$currentConversationId()]
const isLoading = () => !!$loadingStateMap()[$currentConversationId()]
// const isStreaming = () => !!$streamsMap()[$currentConversationId()]
// const isLoading = () => !!$loadingStateMap()[$currentConversationId()]

createEffect(() => {
const conversation = currentConversation()
document.title = conversation ? `${(conversation.name || t('conversations.untitled'))} • Anse` : 'Anse'
const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement
if (link) {
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
link.setAttribute('href', conversationIcon || '/logo.svg')
}
})

return (
<Switch
Expand Down

0 comments on commit 600a273

Please sign in to comment.