From b4f08a0e9c730087e66fd6e3ff0930aa199dd7c9 Mon Sep 17 00:00:00 2001 From: Natalia Bandurova Date: Sat, 2 Nov 2024 12:29:20 +0300 Subject: [PATCH] refactor: simplify channelsApi --- frontend/src/api/channelsApi.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/api/channelsApi.js b/frontend/src/api/channelsApi.js index d91226a..2b5319c 100644 --- a/frontend/src/api/channelsApi.js +++ b/frontend/src/api/channelsApi.js @@ -8,13 +8,11 @@ export const channelsApi = createApi({ baseUrl: getApiPath(CHANNELS_PATH), prepareHeaders, }), - tagTypes: ['Channels'], + tagTypes: ['Channels', 'Messages'], endpoints: (builder) => ({ getChannels: builder.query({ query: () => '', - providesTags: (result) => (result - ? [...result.map(({ id }) => ({ type: 'Channels', id })), { type: 'Channels', id: 'LIST' }] - : [{ type: 'Channels', id: 'LIST' }]), + providesTags: ['Channels'], }), addChannel: builder.mutation({ @@ -29,7 +27,7 @@ export const channelsApi = createApi({ method: 'DELETE', url: id, }), - invalidatesTags: (id) => [{ type: 'Channels', id }], + invalidatesTags: ['Channels', 'Messages'], }), editChannel: builder.mutation({ @@ -38,7 +36,6 @@ export const channelsApi = createApi({ url: channel.id, body: channel, }), - invalidatesTags: ({ id }) => [{ type: 'Channels', id }], }), }), });