feat: remember UI state

This commit is contained in:
zerosoul
2022-03-28 20:42:22 +08:00
parent f039668d4f
commit 28bc1cfbcd
7 changed files with 87 additions and 0 deletions
+12
View File
@@ -18,6 +18,18 @@ export const onMessageSendStarted = async (
) => {
// id: who send to ,from_uid: who sent
const ts = properties.local_id || new Date().getTime();
// let imageData = null;
// if (type == "image") {
// if (typeof content == "string" && content.startsWith("data:image")) {
// // base64
// // const resp = await fetch(content);
// // const blob = await resp.blob();
// // imageData = new File([blob], "tmp.png", { type: "image/png" });
// imageData = content;
// } else {
// imageData = URL.createObjectURL(content);
// }
// }
const tmpMsg = {
content: type == "image" ? URL.createObjectURL(content) : content,
content_type: ContentTypes[type],
+22
View File
@@ -38,6 +38,26 @@ export const messageApi = createApi({
method: "DELETE",
}),
}),
prepareUploadFile: builder.mutation({
query: () => ({
url: `/resource/file/prepare`,
method: "POST",
}),
}),
uploadFile: builder.mutation({
query: (formData) => ({
// headers: {
// "content-type": ContentTypes.formData,
// },
url: `/resource/file/upload`,
method: "POST",
body: formData,
}),
transformResponse: (data) => {
console.log("upload file response", data);
return data ? data : {};
},
}),
uploadImage: builder.mutation({
query: (image) => ({
headers: {
@@ -102,6 +122,8 @@ export const messageApi = createApi({
});
export const {
usePrepareUploadFileMutation,
useUploadFileMutation,
useUploadImageMutation,
useEditMessageMutation,
useReactMessageMutation,