refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-22 21:19:49 +08:00
parent 6427af90ef
commit dae0b80ee0
20 changed files with 81 additions and 88 deletions
+5 -1
View File
@@ -27,7 +27,11 @@ import { StyledUsers, StyledChannelChat, StyledHeader } from "./styled";
import InviteModal from "../../../common/component/InviteModal";
import LoadMore from "../LoadMore";
import { useAppSelector } from "../../../app/store";
export default function ChannelChat({ cid = "", dropFiles = [] }) {
type Props = {
cid?: number;
dropFiles?: File[];
};
export default function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
const { values: agoraConfig } = useConfig("agora");
const {
list: msgIds,
+1 -1
View File
@@ -14,7 +14,7 @@ interface Props {
header: ReactElement;
aside: ReactElement | null;
users?: ReactElement;
dropFiles: [File];
dropFiles: File[];
context: "channel" | "user";
to: number;
}
+9 -2
View File
@@ -6,6 +6,7 @@ import Toggle from "../../../common/component/styled/Toggle";
import Label from "../../../common/component/styled/Label";
import SaveTip from "../../../common/component/SaveTip";
import useConfig from "../../../common/hook/useConfig";
import { FirebaseConfig } from "../../../types/server";
export default function ConfigFirebase() {
const { values, toggleEnable, updateConfig, setValues, reset, changed } = useConfig("firebase");
@@ -20,8 +21,14 @@ export default function ConfigFirebase() {
return { ...prev, [type]: newValue };
});
};
// if (!values) return null;
const { token_url, project_id, private_key, client_email, enabled = false } = values ?? {};
if (!values) return null;
const {
token_url,
project_id,
private_key,
client_email,
enabled = false
} = values as FirebaseConfig;
return (
<StyledContainer>
<div className="inputs">
-1
View File
@@ -49,7 +49,6 @@ export default function Logins() {
};
const handleGithubAuthChange = (evt) => {
const { key } = evt.target.dataset;
console.log("ggg", key, evt.target.value);
if (key) {
updateGithubAuthConfig({ [key]: evt.target.value });
}