Skip to content

Commit

Permalink
Rename validateToken func
Browse files Browse the repository at this point in the history
  • Loading branch information
jmetrikat committed Feb 24, 2025
1 parent 5d8cdbe commit 5465eb6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/api/validateToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { apiFetch } from "../helpers/api";
import { apiEndpoints, currentApiVersion, errorConnectionMessage } from "../helpers/constants";
import { PaginatedResponse, Space } from "../helpers/schemas";

// Validate token by checking if data can be fetched without errors
export async function validateToken(): Promise<boolean> {
// Validate api version and token by checking if data can be fetched without errors
export async function checkApiTokenValidity(): Promise<boolean> {
try {
const { url, method } = apiEndpoints.getSpaces({ offset: 0, limit: 1 });
const response = await apiFetch<PaginatedResponse<Space>>(url, { method: method });
Expand Down
4 changes: 2 additions & 2 deletions src/components/EnsureAuthenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useForm } from "@raycast/utils";
import { useEffect, useState } from "react";
import { displayCode } from "../api/displayCode";
import { getToken } from "../api/getToken";
import { validateToken } from "../api/validateToken";
import { checkApiTokenValidity } from "../api/validateToken";
import { apiAppName, downloadUrl, localStorageKeys } from "../helpers/constants";

type EnsureAuthenticatedProps = {
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function EnsureAuthenticated({ placeholder, viewType, children }:
const retrieveAndValidateToken = async () => {
const token = await LocalStorage.getItem<string>(localStorageKeys.appKey);
if (token) {
const isValid = await validateToken();
const isValid = await checkApiTokenValidity();
setHasToken(true);
setTokenIsValid(isValid);
} else {
Expand Down

0 comments on commit 5465eb6

Please sign in to comment.