chore(refactor): improve stores/config
types (#3190)
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/3190 Reviewed-by: konrad <k@knt.li> Co-authored-by: WofWca <wofwca@protonmail.com> Co-committed-by: WofWca <wofwca@protonmail.com>
This commit is contained in:
parent
f1ec554d09
commit
6a3518dace
@ -113,8 +113,8 @@ export const checkAndSetApiUrl = (url: string): Promise<string> => {
|
|||||||
window.API_URL = oldUrl
|
window.API_URL = oldUrl
|
||||||
throw e
|
throw e
|
||||||
})
|
})
|
||||||
.then(r => {
|
.then(success => {
|
||||||
if (typeof r !== 'undefined') {
|
if (success) {
|
||||||
localStorage.setItem('API_URL', window.API_URL)
|
localStorage.setItem('API_URL', window.API_URL)
|
||||||
return window.API_URL
|
return window.API_URL
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import {HTTPFactory} from '@/helpers/fetcher'
|
|||||||
import {objectToCamelCase} from '@/helpers/case'
|
import {objectToCamelCase} from '@/helpers/case'
|
||||||
|
|
||||||
import type {IProvider} from '@/types/IProvider'
|
import type {IProvider} from '@/types/IProvider'
|
||||||
|
import type {MIGRATORS} from '@/views/migrate/migrators'
|
||||||
|
|
||||||
export interface ConfigState {
|
export interface ConfigState {
|
||||||
version: string,
|
version: string,
|
||||||
@ -14,10 +15,10 @@ export interface ConfigState {
|
|||||||
linkSharingEnabled: boolean,
|
linkSharingEnabled: boolean,
|
||||||
maxFileSize: string,
|
maxFileSize: string,
|
||||||
registrationEnabled: boolean,
|
registrationEnabled: boolean,
|
||||||
availableMigrators: [],
|
availableMigrators: Array<keyof typeof MIGRATORS>,
|
||||||
taskAttachmentsEnabled: boolean,
|
taskAttachmentsEnabled: boolean,
|
||||||
totpEnabled: boolean,
|
totpEnabled: boolean,
|
||||||
enabledBackgroundProviders: [],
|
enabledBackgroundProviders: Array<'unsplash' | 'upload'>,
|
||||||
legal: {
|
legal: {
|
||||||
imprintUrl: string,
|
imprintUrl: string,
|
||||||
privacyPolicyUrl: string,
|
privacyPolicyUrl: string,
|
||||||
@ -78,11 +79,12 @@ export const useConfigStore = defineStore('config', () => {
|
|||||||
function setConfig(config: ConfigState) {
|
function setConfig(config: ConfigState) {
|
||||||
Object.assign(state, config)
|
Object.assign(state, config)
|
||||||
}
|
}
|
||||||
async function update() {
|
async function update(): Promise<boolean> {
|
||||||
const HTTP = HTTPFactory()
|
const HTTP = HTTPFactory()
|
||||||
const {data: config} = await HTTP.get('info')
|
const {data: config} = await HTTP.get('info')
|
||||||
setConfig(objectToCamelCase(config))
|
setConfig(objectToCamelCase(config))
|
||||||
return config
|
const success = !!config
|
||||||
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -16,7 +16,7 @@ interface IMigratorRecord {
|
|||||||
[key: Migrator['id']]: Migrator
|
[key: Migrator['id']]: Migrator
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MIGRATORS: IMigratorRecord = {
|
export const MIGRATORS = {
|
||||||
wunderlist: {
|
wunderlist: {
|
||||||
id: 'wunderlist',
|
id: 'wunderlist',
|
||||||
name: 'Wunderlist',
|
name: 'Wunderlist',
|
||||||
@ -49,4 +49,4 @@ export const MIGRATORS: IMigratorRecord = {
|
|||||||
icon: tickTickIcon as string,
|
icon: tickTickIcon as string,
|
||||||
isFileMigrator: true,
|
isFileMigrator: true,
|
||||||
},
|
},
|
||||||
} as const
|
} as const satisfies IMigratorRecord
|
||||||
|
Loading…
x
Reference in New Issue
Block a user