refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-29 08:49:34 +08:00
parent 43a13f8d08
commit 96017c8fc6
21 changed files with 150 additions and 90 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ export const authApi = createApi({
}
}),
// 更新 device token
updateDeviceToken: builder.mutation<void, { device_token: string }>({
updateDeviceToken: builder.mutation<void, string>({
query: (device_token) => ({
url: "/token/device_token",
method: "PUT",
+1 -1
View File
@@ -19,7 +19,7 @@ const favoritesSlice = createSlice({
addFavorite(state, action: PayloadAction<Favorite>) {
state.push(action.payload);
},
deleteFavorite(state, action: PayloadAction<number>) {
deleteFavorite(state, action: PayloadAction<string>) {
const id = action.payload;
const idx = state.findIndex((f) => f.id == id);
if (idx > -1) {
+7 -7
View File
@@ -1,13 +1,6 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import BASE_URL, { ContentTypes } from "../config";
import { isImage } from "../../common/utils";
export interface State {
[key: number]: object;
replying: {
[key: string | number]: number;
};
}
export interface MessagePayload {
mid: number;
sending: boolean;
@@ -21,6 +14,13 @@ export interface MessagePayload {
download?: string;
thumbnail?: string;
}
export interface State {
[key: number]: MessagePayload;
replying: {
[key: string | number]: number;
};
}
const initialState: State = {
replying: {}
};