fix(ui): fix rtk tags

I had mixed up `type` and `id` on a bunch of the tags. Fixing those
This commit is contained in:
psychedelicious 2023-07-14 15:32:09 +10:00
parent abe2a0f9b4
commit d858a0c5d8
3 changed files with 28 additions and 20 deletions

View File

@ -25,11 +25,12 @@ export const boardImagesApi = api.injectEndpoints({
query: ({ board_id, offset, limit }) => ({ query: ({ board_id, offset, limit }) => ({
url: `board_images/${board_id}`, url: `board_images/${board_id}`,
method: 'GET', method: 'GET',
}), }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
// any list of boardimages // any list of boardimages
const tags: ApiFullTagDescription[] = [{ id: 'BoardImage', type: `${arg.board_id}_${LIST_TAG}` }]; const tags: ApiFullTagDescription[] = [
{ type: 'BoardImage', id: `${arg.board_id}_${LIST_TAG}` },
];
if (result) { if (result) {
// and individual tags for each boardimage // and individual tags for each boardimage
@ -57,7 +58,7 @@ export const boardImagesApi = api.injectEndpoints({
}), }),
invalidatesTags: (result, error, arg) => [ invalidatesTags: (result, error, arg) => [
{ type: 'BoardImage' }, { type: 'BoardImage' },
{ type: 'Board', id: arg.board_id } { type: 'Board', id: arg.board_id },
], ],
}), }),
@ -69,7 +70,7 @@ export const boardImagesApi = api.injectEndpoints({
}), }),
invalidatesTags: (result, error, arg) => [ invalidatesTags: (result, error, arg) => [
{ type: 'BoardImage' }, { type: 'BoardImage' },
{ type: 'Board', id: arg.board_id } { type: 'Board', id: arg.board_id },
], ],
}), }),
}), }),

View File

@ -20,7 +20,7 @@ export const boardsApi = api.injectEndpoints({
query: (arg) => ({ url: 'boards/', params: arg }), query: (arg) => ({ url: 'boards/', params: arg }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
// any list of boards // any list of boards
const tags: ApiFullTagDescription[] = [{ id: 'Board', type: LIST_TAG }]; const tags: ApiFullTagDescription[] = [{ type: 'Board', id: LIST_TAG }];
if (result) { if (result) {
// and individual tags for each board // and individual tags for each board
@ -43,7 +43,7 @@ export const boardsApi = api.injectEndpoints({
}), }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
// any list of boards // any list of boards
const tags: ApiFullTagDescription[] = [{ id: 'Board', type: LIST_TAG }]; const tags: ApiFullTagDescription[] = [{ type: 'Board', id: LIST_TAG }];
if (result) { if (result) {
// and individual tags for each board // and individual tags for each board
@ -69,7 +69,7 @@ export const boardsApi = api.injectEndpoints({
method: 'POST', method: 'POST',
params: { board_name }, params: { board_name },
}), }),
invalidatesTags: [{ id: 'Board', type: LIST_TAG }], invalidatesTags: [{ type: 'Board', id: LIST_TAG }],
}), }),
updateBoard: build.mutation<BoardDTO, UpdateBoardArg>({ updateBoard: build.mutation<BoardDTO, UpdateBoardArg>({
@ -87,8 +87,15 @@ export const boardsApi = api.injectEndpoints({
invalidatesTags: (result, error, arg) => [{ type: 'Board', id: arg }], invalidatesTags: (result, error, arg) => [{ type: 'Board', id: arg }],
}), }),
deleteBoardAndImages: build.mutation<void, string>({ deleteBoardAndImages: build.mutation<void, string>({
query: (board_id) => ({ url: `boards/${board_id}`, method: 'DELETE', params: { include_images: true } }), query: (board_id) => ({
invalidatesTags: (result, error, arg) => [{ type: 'Board', id: arg }, { type: 'Image', id: LIST_TAG }], url: `boards/${board_id}`,
method: 'DELETE',
params: { include_images: true },
}),
invalidatesTags: (result, error, arg) => [
{ type: 'Board', id: arg },
{ type: 'Image', id: LIST_TAG },
],
}), }),
}), }),
}); });
@ -99,5 +106,5 @@ export const {
useCreateBoardMutation, useCreateBoardMutation,
useUpdateBoardMutation, useUpdateBoardMutation,
useDeleteBoardMutation, useDeleteBoardMutation,
useDeleteBoardAndImagesMutation useDeleteBoardAndImagesMutation,
} = boardsApi; } = boardsApi;

View File

@ -99,7 +99,7 @@ export const modelsApi = api.injectEndpoints({
query: () => ({ url: 'models/', params: { model_type: 'main' } }), query: () => ({ url: 'models/', params: { model_type: 'main' } }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
const tags: ApiFullTagDescription[] = [ const tags: ApiFullTagDescription[] = [
{ id: 'MainModel', type: LIST_TAG }, { type: 'MainModel', id: LIST_TAG },
]; ];
if (result) { if (result) {
@ -138,7 +138,7 @@ export const modelsApi = api.injectEndpoints({
body: body, body: body,
}; };
}, },
invalidatesTags: ['MainModel'], invalidatesTags: [{ type: 'MainModel', id: LIST_TAG }],
}), }),
deleteMainModels: build.mutation< deleteMainModels: build.mutation<
EntityState<MainModelConfigEntity>, EntityState<MainModelConfigEntity>,
@ -150,7 +150,7 @@ export const modelsApi = api.injectEndpoints({
method: 'DELETE', method: 'DELETE',
}; };
}, },
invalidatesTags: ['MainModel'], invalidatesTags: [{ type: 'MainModel', id: LIST_TAG }],
}), }),
convertMainModels: build.mutation< convertMainModels: build.mutation<
EntityState<MainModelConfigEntity>, EntityState<MainModelConfigEntity>,
@ -162,7 +162,7 @@ export const modelsApi = api.injectEndpoints({
method: 'PUT', method: 'PUT',
}; };
}, },
invalidatesTags: ['MainModel'], invalidatesTags: [{ type: 'MainModel', id: LIST_TAG }],
}), }),
mergeMainModels: build.mutation< mergeMainModels: build.mutation<
EntityState<MainModelConfigEntity>, EntityState<MainModelConfigEntity>,
@ -175,13 +175,13 @@ export const modelsApi = api.injectEndpoints({
body: body, body: body,
}; };
}, },
invalidatesTags: ['MainModel'], invalidatesTags: [{ type: 'MainModel', id: LIST_TAG }],
}), }),
getLoRAModels: build.query<EntityState<LoRAModelConfigEntity>, void>({ getLoRAModels: build.query<EntityState<LoRAModelConfigEntity>, void>({
query: () => ({ url: 'models/', params: { model_type: 'lora' } }), query: () => ({ url: 'models/', params: { model_type: 'lora' } }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
const tags: ApiFullTagDescription[] = [ const tags: ApiFullTagDescription[] = [
{ id: 'LoRAModel', type: LIST_TAG }, { type: 'LoRAModel', id: LIST_TAG },
]; ];
if (result) { if (result) {
@ -216,7 +216,7 @@ export const modelsApi = api.injectEndpoints({
query: () => ({ url: 'models/', params: { model_type: 'controlnet' } }), query: () => ({ url: 'models/', params: { model_type: 'controlnet' } }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
const tags: ApiFullTagDescription[] = [ const tags: ApiFullTagDescription[] = [
{ id: 'ControlNetModel', type: LIST_TAG }, { type: 'ControlNetModel', id: LIST_TAG },
]; ];
if (result) { if (result) {
@ -248,7 +248,7 @@ export const modelsApi = api.injectEndpoints({
query: () => ({ url: 'models/', params: { model_type: 'vae' } }), query: () => ({ url: 'models/', params: { model_type: 'vae' } }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
const tags: ApiFullTagDescription[] = [ const tags: ApiFullTagDescription[] = [
{ id: 'VaeModel', type: LIST_TAG }, { type: 'VaeModel', id: LIST_TAG },
]; ];
if (result) { if (result) {
@ -283,7 +283,7 @@ export const modelsApi = api.injectEndpoints({
query: () => ({ url: 'models/', params: { model_type: 'embedding' } }), query: () => ({ url: 'models/', params: { model_type: 'embedding' } }),
providesTags: (result, error, arg) => { providesTags: (result, error, arg) => {
const tags: ApiFullTagDescription[] = [ const tags: ApiFullTagDescription[] = [
{ id: 'TextualInversionModel', type: LIST_TAG }, { type: 'TextualInversionModel', id: LIST_TAG },
]; ];
if (result) { if (result) {