refactor: more TS code
This commit is contained in:
@@ -126,8 +126,8 @@ export const channelApi = createApi({
|
||||
content: string | object;
|
||||
type: ContentTypeKey;
|
||||
properties?: object;
|
||||
from_uid: number;
|
||||
ignoreLocal: boolean;
|
||||
from_uid?: number;
|
||||
ignoreLocal?: boolean;
|
||||
}
|
||||
>({
|
||||
query: ({ id, content, type = "text", properties = {} }) => ({
|
||||
|
||||
@@ -116,14 +116,14 @@ export const messageApi = createApi({
|
||||
}
|
||||
}
|
||||
}),
|
||||
getFavoriteDetails: builder.query<Archive, number>({
|
||||
getFavoriteDetails: builder.query<Archive, string>({
|
||||
query: (id) => ({
|
||||
url: `/favorite/${id}`
|
||||
}),
|
||||
async onQueryStarted(id, { dispatch, queryFulfilled, getState }) {
|
||||
try {
|
||||
const { data } = await queryFulfilled;
|
||||
const loginUid = (getState() as RootState).authData.user.uid;
|
||||
const loginUid = (getState() as RootState).authData.user?.uid;
|
||||
const messages = normalizeArchiveData(data, id, loginUid);
|
||||
dispatch(populateFavorite({ id, messages }));
|
||||
} catch (err) {
|
||||
|
||||
@@ -2,8 +2,9 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
// import BASE_URL from "../config";
|
||||
|
||||
export interface Favorite {
|
||||
id: number;
|
||||
messages: any[];
|
||||
id: string;
|
||||
created_at?: number;
|
||||
messages?: any[];
|
||||
}
|
||||
|
||||
const initialState: Favorite[] = [];
|
||||
|
||||
Reference in New Issue
Block a user