mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
752 B
26 lines
752 B
2 years ago
|
import type { Getters, State } from './types'
|
||
2 years ago
|
import { computed } from '#imports'
|
||
|
|
||
2 years ago
|
export function useGlobalGetters(state: State): Getters {
|
||
2 years ago
|
/** Verify that a user is signed in by checking if token exists and is not expired */
|
||
|
const signedIn: Getters['signedIn'] = computed(
|
||
|
() =>
|
||
|
!!(
|
||
|
!!state.token &&
|
||
|
state.token.value !== '' &&
|
||
2 years ago
|
state.jwtPayload.value &&
|
||
|
state.jwtPayload.value.exp &&
|
||
|
state.jwtPayload.value.exp > state.timestamp.value / 1000
|
||
2 years ago
|
),
|
||
|
)
|
||
|
|
||
2 years ago
|
/** global loading state */
|
||
|
let loading = $ref(false)
|
||
|
const isLoading = computed({
|
||
2 years ago
|
get: () => state.runningRequests.count.value > 0 || loading,
|
||
2 years ago
|
set: (_loading) => (loading = _loading),
|
||
2 years ago
|
})
|
||
|
|
||
|
return { signedIn, isLoading }
|
||
2 years ago
|
}
|