Skip to content

Commit bb4e7da

Browse files
authored
Fix: web app theme intialization (langgenius#14761)
1 parent 64e122c commit bb4e7da

File tree

6 files changed

+12
-59
lines changed

6 files changed

+12
-59
lines changed

web/app/(shareLayout)/layout.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react'
22
import type { FC } from 'react'
33
import type { Metadata } from 'next'
4-
import { SharePageContextProvider } from '@/context/share-page-context'
54

65
export const metadata: Metadata = {
76
icons: 'data:,', // prevent browser from using default favicon
@@ -12,9 +11,7 @@ const Layout: FC<{
1211
}> = ({ children }) => {
1312
return (
1413
<div className="min-w-[300px] h-full pb-[env(safe-area-inset-bottom)]">
15-
<SharePageContextProvider>
16-
{children}
17-
</SharePageContextProvider>
14+
{children}
1815
</div>
1916
)
2017
}

web/app/components/base/audio-gallery/AudioPlayer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
RiPlayLargeFill,
66
} from '@remixicon/react'
77
import Toast from '@/app/components/base/toast'
8-
import { useAppContext } from '@/context/app-context'
8+
import useTheme from '@/hooks/use-theme'
99
import { Theme } from '@/types/app'
1010
import cn from '@/utils/classnames'
1111

@@ -24,7 +24,7 @@ const AudioPlayer: React.FC<AudioPlayerProps> = ({ src }) => {
2424
const [hasStartedPlaying, setHasStartedPlaying] = useState(false)
2525
const [hoverTime, setHoverTime] = useState(0)
2626
const [isAudioAvailable, setIsAudioAvailable] = useState(true)
27-
const { theme } = useAppContext()
27+
const { theme } = useTheme()
2828

2929
useEffect(() => {
3030
const audio = audioRef.current

web/app/components/base/chat/chat-with-history/chat-wrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const ChatWrapper = () => {
206206
isResponding={isResponding}
207207
chatContainerInnerClassName={`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`}
208208
chatFooterClassName='pb-4'
209-
chatFooterInnerClassName={`mx-auto w-full max-w-[720px] ${isMobile && 'px-4'}`}
209+
chatFooterInnerClassName={`mx-auto w-full max-w-[720px] ${isMobile ? 'px-2' : 'px-4'}`}
210210
onSend={doSend}
211211
inputs={currentConversationId ? currentConversationItem?.inputs as any : newConversationInputs}
212212
inputsForm={inputsForms}

web/app/components/base/chat/embedded-chatbot/theme/theme-context.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ export class ThemeBuilder {
4848
private buildChecker = false
4949

5050
public get theme() {
51-
if (this._theme === undefined)
52-
throw new Error('The theme should be built first and then accessed')
53-
else
51+
if (this._theme === undefined) {
52+
this._theme = new Theme()
5453
return this._theme
54+
}
55+
else {
56+
return this._theme
57+
}
5558
}
5659

5760
public buildTheme(chatColorTheme: string | null = null, chatColorThemeInverted = false) {

web/app/components/base/markdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import MarkdownButton from '@/app/components/base/markdown-blocks/button'
2626
import MarkdownForm from '@/app/components/base/markdown-blocks/form'
2727
import ThinkBlock from '@/app/components/base/markdown-blocks/think-block'
2828
import { Theme } from '@/types/app'
29-
import { useAppContext } from '@/context/app-context'
29+
import useTheme from '@/hooks/use-theme'
3030
import cn from '@/utils/classnames'
3131

3232
// Available language https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_HLJS.MD
@@ -107,7 +107,7 @@ export function PreCode(props: { children: any }) {
107107
// or use the non-minified dev environment for full errors and additional helpful warnings.
108108

109109
const CodeBlock: any = memo(({ inline, className, children, ...props }: any) => {
110-
const { theme } = useAppContext()
110+
const { theme } = useTheme()
111111
const [isSVG, setIsSVG] = useState(true)
112112
const match = /language-(\w+)/.exec(className || '')
113113
const language = match?.[1]

web/context/share-page-context.tsx

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)