diff --git a/src/app/services/channel.ts b/src/app/services/channel.ts index eacaab10..c7c1378a 100644 --- a/src/app/services/channel.ts +++ b/src/app/services/channel.ts @@ -35,7 +35,7 @@ export const channelApi = createApi({ } } }), - createChannel: builder.mutation({ + createChannel: builder.mutation({ query: (data) => ({ url: "group", method: "POST", diff --git a/src/common/component/ChannelModal/index.tsx b/src/common/component/ChannelModal/index.tsx index 2f6fd35a..c6d9e24c 100644 --- a/src/common/component/ChannelModal/index.tsx +++ b/src/common/component/ChannelModal/index.tsx @@ -33,7 +33,7 @@ const ChannelModal: FC = ({ personal = false, closeModal }) => { }); const { users, input, updateInput } = useFilteredUsers(); - const [createChannel, { isSuccess, isError, isLoading, data: newChannelId }] = + const [createChannel, { isSuccess, isError, isLoading, data: newChannel }] = useCreateChannelMutation(); const handleToggle = () => { @@ -63,12 +63,13 @@ const ChannelModal: FC = ({ personal = false, closeModal }) => { }, [isError]); useEffect(() => { - if (isSuccess) { + if (isSuccess && newChannel) { toast.success("create new channel success"); closeModal(); - navigateTo(`/chat/channel/${newChannelId}`); + const id = typeof newChannel == 'object' ? newChannel.gid : newChannel; + navigateTo(`/chat/channel/${id}`); } - }, [isSuccess, newChannelId]); + }, [isSuccess, newChannel]); const handleNameInput = (evt: ChangeEvent) => { setData((prev) => ({ ...prev, name: evt.target.value }));