jan/web/helpers/atoms/App.atom.ts
Louis dc06a07c71
Merge branch 'release/v0.5.15' into chore/sync-release-to-dev
# Conflicts:
#	extensions/engine-management-extension/rolldown.config.mjs
#	extensions/inference-cortex-extension/bin/version.txt
#	extensions/yarn.lock
#	web/containers/Layout/BottomPanel/SystemMonitor/index.tsx
#	web/containers/ModelDropdown/index.tsx
#	web/containers/ModelLabel/ModelLabel.test.tsx
#	web/screens/Settings/HuggingFaceRepoDetailModal/ModelDownloadRow/index.tsx
#	web/screens/Thread/ThreadCenterPanel/TextMessage/MarkdownTextMessage.tsx
#	web/screens/Thread/ThreadCenterPanel/TextMessage/index.tsx
#	yarn.lock
2025-02-18 16:33:58 +07:00

64 lines
1.7 KiB
TypeScript

import { atom } from 'jotai'
import { atomWithStorage } from 'jotai/utils'
import { MainViewState } from '@/constants/screens'
export const mainViewStateAtom = atom<MainViewState>(MainViewState.Thread)
export const defaultJanDataFolderAtom = atom<string>('')
export const LocalEngineDefaultVariantAtom = atom<string>('')
const SHOW_RIGHT_PANEL = 'showRightPanel'
// Store panel atom
export const showLeftPanelAtom = atom<boolean>(true)
export const showRightPanelAtom = atomWithStorage<boolean>(
SHOW_RIGHT_PANEL,
false,
undefined,
{ getOnInit: true }
)
export const showSystemMonitorPanelAtom = atom<boolean>(false)
export const appDownloadProgressAtom = atom<number>(-1)
export const updateVersionErrorAtom = atom<string | undefined>(undefined)
export const appUpdateAvailableAtom = atom<boolean>(false)
export const appUpdateNotAvailableAtom = atom<boolean>(false)
const COPY_OVER_INSTRUCTION_ENABLED = 'copy_over_instruction_enabled'
export const copyOverInstructionEnabledAtom = atomWithStorage(
COPY_OVER_INSTRUCTION_ENABLED,
false
)
/**
* App Banner Hub Atom - storage last banner setting - default undefined
*/
const appBannerHubStorageAtom = atomWithStorage<string | undefined>(
'appBannerHub',
undefined,
undefined,
{
getOnInit: true,
}
)
/**
* App Hub Banner configured image - Retrieve from appBannerHubStorageAtom - fallback a random banner
*/
export const getAppBannerHubAtom = atom<string>(
(get) =>
get(appBannerHubStorageAtom) ??
`./images/HubBanner/banner-${Math.floor(Math.random() * 30) + 1}.jpg`
)
/**
* Set App Hub Banner - store in appBannerHubStorageAtom
*/
export const setAppBannerHubAtom = atom(null, (get, set, banner: string) => {
set(appBannerHubStorageAtom, banner)
})