import { checkAuth } from '@/api'

let authChecked = false
let isAuth = false

export async function getAuthStatus(force = false): Promise<boolean> {
  if (!force && authChecked) return isAuth
  isAuth = await checkAuth()
  authChecked = true
  return isAuth
}

export function resetAuthCache() {
  authChecked = false
  isAuth = false
}

export function setAuthCache(status: boolean) {
  authChecked = true
  isAuth = status
}
