Skip to content

Commit

Permalink
show modal only on api key error
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 committed Dec 29, 2023
1 parent 1ba60e9 commit c321f28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const authenticate = async () => {
hasError.value = false
updateAuthKey(authKey.value)
const status = await getStatus()
hasError.value = status == undefined
hasError.value = status == 'Invalid API Key'
if (!hasError.value) {
authBox.value?.toggleModal()
isReadyAndAuth.value = true
Expand All @@ -32,7 +32,7 @@ const currentComponentLoading = computed(() => {
const routeName = route.name?.toString()
let store
if (routeName !== undefined && !routesToExclude.includes(routeName)) {
store = storeMapping[routeName]
store = storeMapping[routeName as keyof typeof storeMapping]
const { currentState } = storeToRefs(store)
return store && currentState.value.loading
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export const useSettings = defineStore('settings', () => {

const getStatus = async () => {
const result = await tryRequest(apiClient.api?.status.home(), 'Getting Cheshire Cat status', 'Unable to fetch Cheshire Cat status')
return result.data
return result.data ?? result.message
}

const { state: cat } = useAsyncState(getStatus, {} as Status)

watchEffect(() => {
isReadyAndAuth.value = cat.value != undefined
isReadyAndAuth.value = cat.value != 'Invalid API Key'
})

return {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/storeRouteMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function useStoreMapping() {
const storePlugins = usePlugins()
const storeMemory = useMemory()

const storeMapping: Record<string, typeof storeEmbedder | typeof storeLLM | typeof storeMemory | typeof storePlugins> = {
const storeMapping = {
embedders: storeEmbedder,
providers: storeLLM,
memory: storeMemory,
Expand Down
3 changes: 2 additions & 1 deletion src/views/SettingsView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import SidePanel from '@components/SidePanel.vue'
import { useSettings } from '@stores/useSettings'
defineProps<{
loading: boolean
}>()
Expand All @@ -27,7 +28,7 @@ const openSidePanel = (title: keyof typeof panelTitles) => {
<p class="text-lg font-bold">
Cheshire Cat AI - Version
<span class="text-primary">
{{ cat?.version ?? 'unknown' }}
{{ typeof cat == 'string' ? 'unknown' : cat.version }}
</span>
</p>
</div>
Expand Down

0 comments on commit c321f28

Please sign in to comment.