feat: settings & solid login

This commit is contained in:
zerosoul
2022-02-27 12:30:14 +08:00
parent 0394c99292
commit f7634a59cd
35 changed files with 1552 additions and 246 deletions
+26
View File
@@ -4,6 +4,7 @@ import toast from "react-hot-toast";
import baseQuery from "./base.query";
import { ContentTypes } from "../config";
import { addChannelMsg } from "../slices/message.channel";
import { updateChannel } from "../slices/channels";
import {
addPendingMessage,
removePendingMessage,
@@ -21,6 +22,9 @@ export const channelApi = createApi({
getChannels: builder.query({
query: () => ({ url: `group` }),
}),
getChannel: builder.query({
query: (id) => ({ url: `group/${id}` }),
}),
createChannel: builder.mutation({
query: (data) => ({
url: "group",
@@ -28,6 +32,26 @@ export const channelApi = createApi({
body: data,
}),
}),
updateChannel: builder.mutation({
query: ({ id, ...data }) => ({
url: `group/${id}`,
method: "PUT",
body: data,
}),
async onQueryStarted(
{ id, name, description },
{ dispatch, queryFulfilled }
) {
// id: who send to ,from_uid: who sent
const patchResult = dispatch(updateChannel({ id, name, description }));
try {
await queryFulfilled;
} catch {
console.log("channel update failed");
patchResult.undo();
}
},
}),
removeChannel: builder.query({
query: (id) => ({
url: `group/${id}`,
@@ -78,6 +102,8 @@ export const channelApi = createApi({
});
export const {
useGetChannelQuery,
useUpdateChannelMutation,
useLazyRemoveChannelQuery,
useGetChannelsQuery,
useCreateChannelMutation,