refactor: improve stores/config
types #3190
|
@ -113,8 +113,8 @@ export const checkAndSetApiUrl = (url: string): Promise<string> => {
|
|||
window.API_URL = oldUrl
|
||||
throw e
|
||||
})
|
||||
.then(r => {
|
||||
if (typeof r !== 'undefined') {
|
||||
.then(success => {
|
||||
if (success) {
|
||||
localStorage.setItem('API_URL', window.API_URL)
|
||||
return window.API_URL
|
||||
}
|
||||
|
|
|
@ -79,11 +79,12 @@ export const useConfigStore = defineStore('config', () => {
|
|||
function setConfig(config: ConfigState) {
|
||||
Object.assign(state, config)
|
||||
}
|
||||
async function update() {
|
||||
async function update(): Promise<boolean> {
|
||||
const HTTP = HTTPFactory()
|
||||
const {data: config} = await HTTP.get('info')
|
||||
setConfig(objectToCamelCase(config))
|
||||
return config
|
||||
const success = !!config
|
||||
return success
|
||||
konrad marked this conversation as resolved
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Reference in New Issue
Why not
Boolean(config)
? Or something likeObject.keys(config).length > 0
?No particular reason. I'm just used to
!!
, and I tried to keep the logic the same.Fair enough.