feat: lots of updates

This commit is contained in:
zerosoul
2022-01-27 22:06:44 +08:00
commit e18c7323a6
72 changed files with 12432 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import { createApi } from "@reduxjs/toolkit/query/react";
import baseQuery from "./base.query";
import { REHYDRATE } from "redux-persist";
export const channelApi = createApi({
reducerPath: "groups",
baseQuery,
extractRehydrationInfo(action, { reducerPath }) {
if (action.type === REHYDRATE) {
return action.payload ? action.payload[reducerPath] : undefined;
}
},
refetchOnFocus: true,
endpoints: (builder) => ({
getChannels: builder.query({
query: () => ({ url: `group` }),
}),
createChannel: builder.mutation({
query: (data) => ({
url: "group",
method: "POST",
body: data,
}),
}),
sendChannelMsg: builder.mutation({
query: ({ gid, message }) => ({
url: `group/${gid}/send`,
method: "POST",
body: message,
}),
}),
}),
});
export const {
useGetChannelsQuery,
useCreateChannelMutation,
useSendChannelMsgMutation,
} = channelApi;