refactor: more TS code
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { useEffect } from "react";
|
||||
import PWABadge from "pwa-badge";
|
||||
|
||||
export default function usePWABadge() {
|
||||
// Create an Instance
|
||||
const badge = new PWABadge();
|
||||
useEffect(() => {
|
||||
if (badge.isSupported()) {
|
||||
badge.asyncSetBadge(2).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
return {
|
||||
isSupported: badge.isSupported()
|
||||
};
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export default function usePinMessage(cid: number) {
|
||||
};
|
||||
});
|
||||
const [pin, { isError, isLoading, isSuccess }] = usePinMessageMutation();
|
||||
const [unpin, { isError: isUnpinError, isLoading: isUnpining, isSuccess: isUnpinSuccess }] =
|
||||
const [unpin, { isError: isUnpinError, isLoading: isUnpinning, isSuccess: isUnpinSuccess }] =
|
||||
useUnpinMessageMutation();
|
||||
const pinMessage = (mid: number) => {
|
||||
if (!mid || !cid) return;
|
||||
@@ -46,7 +46,7 @@ export default function usePinMessage(cid: number) {
|
||||
isPining: isLoading,
|
||||
isSuccess,
|
||||
isUnpinError,
|
||||
isUnpining,
|
||||
isUnpinning,
|
||||
isUnpinSuccess
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@ interface SendMessagesDTO {
|
||||
}
|
||||
|
||||
interface SendMessageDTO {
|
||||
type: "text";
|
||||
content: string;
|
||||
properties: object;
|
||||
reply_mid?: number;
|
||||
context: "user" | "channel";
|
||||
from: number;
|
||||
to: number;
|
||||
}
|
||||
|
||||
export default function useSendMessage(props?: Props) {
|
||||
const { context = "user", from = null, to = null } = props || {};
|
||||
const useSendMessage = (props: Props) => {
|
||||
const { context = "user", from, to = null } = props;
|
||||
const dispatch = useAppDispatch();
|
||||
const stageFiles = useAppSelector((store) => store.ui.uploadFiles[`${context}_${to}`] || []);
|
||||
const [replyMessage, { isError: replyErr, isLoading: replying, isSuccess: replySuccess }] =
|
||||
@@ -110,4 +109,5 @@ export default function useSendMessage(props?: Props) {
|
||||
isSending: userSending || channelSending || replying,
|
||||
isSuccess: channelSuccess || userSuccess || replySuccess
|
||||
};
|
||||
}
|
||||
};
|
||||
export default useSendMessage;
|
||||
|
||||
Reference in New Issue
Block a user