mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-26 06:04:08 +00:00
fix(raycast): allow scoped keys on supported commands (#1513)
This commit is contained in:
parent
87af03a55f
commit
848e5ac369
3 changed files with 7 additions and 22 deletions
|
|
@ -214,9 +214,3 @@ export async function searchMemories(
|
|||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to check if API key is configured and valid
|
||||
export async function fetchSettings(): Promise<object> {
|
||||
const response = await makeAuthenticatedRequest<object>("/v3/settings")
|
||||
return response
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ import { fetchProjects, addProject } from "./api"
|
|||
import {
|
||||
FormValidation,
|
||||
showFailureToast,
|
||||
useCachedPromise,
|
||||
useForm,
|
||||
usePromise,
|
||||
} from "@raycast/utils"
|
||||
import { withSupermemory } from "./withSupermemory"
|
||||
|
||||
export default withSupermemory(Command)
|
||||
|
||||
function Command() {
|
||||
const { isLoading, data: projects, mutate } = useCachedPromise(fetchProjects)
|
||||
const { isLoading, data: projects, mutate } = usePromise(fetchProjects)
|
||||
|
||||
return (
|
||||
<List isLoading={isLoading} searchBarPlaceholder="Search your projects">
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import { usePromise } from "@raycast/utils"
|
||||
import { fetchSettings } from "./api"
|
||||
import {
|
||||
Action,
|
||||
ActionPanel,
|
||||
Detail,
|
||||
getPreferenceValues,
|
||||
Icon,
|
||||
List,
|
||||
openExtensionPreferences,
|
||||
|
|
@ -12,18 +10,11 @@ import type { ComponentType } from "react"
|
|||
|
||||
export function withSupermemory<P extends object>(Component: ComponentType<P>) {
|
||||
return function SupermemoryWrappedComponent(props: P) {
|
||||
const { isLoading, data } = usePromise(fetchSettings, [], {
|
||||
failureToastOptions: {
|
||||
title: "Invalid API Key",
|
||||
message:
|
||||
"Invalid API key. Please check your API key in preferences. Get a new one from https://supermemory.link/raycast",
|
||||
},
|
||||
})
|
||||
// Let each command enforce its own endpoint-specific permissions and rate limit.
|
||||
const { apiKey } = getPreferenceValues<Preferences>()
|
||||
|
||||
if (!data) {
|
||||
return isLoading ? (
|
||||
<Detail isLoading />
|
||||
) : (
|
||||
if (!apiKey.trim()) {
|
||||
return (
|
||||
<List>
|
||||
<List.EmptyView
|
||||
icon={Icon.ExclamationMark}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue