|
@@ -1,7 +1,7 @@
|
|
|
// noinspection JSCheckFunctionSignatures
|
|
// noinspection JSCheckFunctionSignatures
|
|
|
|
|
|
|
|
export const characterQueryKeys = {
|
|
export const characterQueryKeys = {
|
|
|
- root: ["characterList"],
|
|
|
|
|
|
|
+ root: ["characters"],
|
|
|
options: () => [...characterQueryKeys.root, "options"],
|
|
options: () => [...characterQueryKeys.root, "options"],
|
|
|
byId: (id) => ["character", id]
|
|
byId: (id) => ["character", id]
|
|
|
}
|
|
}
|
|
@@ -18,20 +18,5 @@ export const characterOptionsQuery = defineQueryOptions({
|
|
|
|
|
|
|
|
export const characterByIdQuery = defineQueryOptions((id) => ({
|
|
export const characterByIdQuery = defineQueryOptions((id) => ({
|
|
|
key: characterQueryKeys.byId(id),
|
|
key: characterQueryKeys.byId(id),
|
|
|
-
|
|
|
|
|
- query: async () => {
|
|
|
|
|
- const { data: characterList } = await usePrefetchCharacterList()
|
|
|
|
|
-
|
|
|
|
|
- if (_isNil(characterList) || _isEmpty(characterList)) {
|
|
|
|
|
- throw new QueryError("error fetching characterList", { key: characterQueryKeys.byId(id) })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const character = _find(characterList, { id })
|
|
|
|
|
-
|
|
|
|
|
- if (_isNil(character)) {
|
|
|
|
|
- throw new QueryError(`character with id ${id} not found`, { key: characterQueryKeys.byId(id) })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return character
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ query: () => useEmit("character:read", id)
|
|
|
}))
|
|
}))
|