refactor: setting page
This commit is contained in:
@@ -72,6 +72,21 @@ export const channelApi = createApi({
|
||||
// }
|
||||
// },
|
||||
}),
|
||||
createInviteLink: builder.query({
|
||||
query: (gid) => ({
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
accept: "text/plain",
|
||||
},
|
||||
url: `/group/${gid}/create_invite_link`,
|
||||
responseHandler: (response) => response.text(),
|
||||
}),
|
||||
transformResponse: (link) => {
|
||||
// 替换掉域名
|
||||
const invite = new URL(link);
|
||||
return `${location.origin}${invite.pathname}${invite.search}${invite.hash}`;
|
||||
},
|
||||
}),
|
||||
removeChannel: builder.query({
|
||||
query: (id) => ({
|
||||
url: `group/${id}`,
|
||||
@@ -126,6 +141,8 @@ export const channelApi = createApi({
|
||||
});
|
||||
|
||||
export const {
|
||||
useLazyCreateInviteLinkQuery,
|
||||
useCreateInviteLinkQuery,
|
||||
useLazyGetHistoryMessagesQuery,
|
||||
useGetChannelQuery,
|
||||
useUpdateChannelMutation,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createApi } from "@reduxjs/toolkit/query/react";
|
||||
import BASE_URL from "../config";
|
||||
import { updateInviteLink, updateInfo } from "../slices/server";
|
||||
import { updateInfo } from "../slices/server";
|
||||
import baseQuery from "./base.query";
|
||||
const defaultExpireDuration = 7 * 24 * 60 * 60;
|
||||
export const serverApi = createApi({
|
||||
@@ -108,18 +108,6 @@ export const serverApi = createApi({
|
||||
const invite = new URL(link);
|
||||
return `${location.origin}${invite.pathname}${invite.search}${invite.hash}`;
|
||||
},
|
||||
async onQueryStarted(
|
||||
expire = defaultExpireDuration,
|
||||
{ dispatch, queryFulfilled }
|
||||
) {
|
||||
try {
|
||||
const { data: link } = await queryFulfilled;
|
||||
console.log("link", link);
|
||||
dispatch(updateInviteLink({ expire, link }));
|
||||
} catch {
|
||||
console.log("invite link error");
|
||||
}
|
||||
},
|
||||
}),
|
||||
updateServer: builder.mutation({
|
||||
query: (data) => ({
|
||||
|
||||
Reference in New Issue
Block a user