Merge branch 'Privoce:main' into feat/add-Japanese-support

This commit is contained in:
Wolfsin
2022-12-04 14:40:07 +09:00
committed by GitHub
6 changed files with 33 additions and 4 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
<center>
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/privoce/vocechat-web/issues)
![GitHub issues](https://img.shields.io/github/issues-raw/Privoce/vocechat-web) ![GitHub](https://img.shields.io/github/license/privoce/vocechat-web) ![GitHub top language](https://img.shields.io/github/languages/top/privoce/vocechat-web)
![GitHub issues](https://img.shields.io/github/issues-raw/Privoce/vocechat-web) ![GitHub](https://img.shields.io/github/license/privoce/vocechat-web) ![GitHub top language](https://img.shields.io/github/languages/top/privoce/vocechat-web) ![Docker Pulls](https://img.shields.io/docker/pulls/privoce/vocechat-server)
</center>
+1 -1
View File
@@ -56,7 +56,7 @@
"title": "Language",
"desc": "Setting the language",
"en": "English",
"zh": "中文",
"zh": "Chinese",
"jp": "Japanese"
}
},
+15 -1
View File
@@ -59,6 +59,20 @@ const authDataSlice = createSlice({
localStorage.setItem(KEY_REFRESH_TOKEN, refresh_token);
localStorage.setItem(KEY_UID, `${uid}`);
},
updateLoginUser(state, { payload }: PayloadAction<Partial<User>>) {
if (!state.user) return;
console.log("upppp", payload);
const obj = { ...state.user, ...payload };
Object.keys(obj).forEach(key => {
// @ts-ignore
if (obj[key] === undefined) {
// @ts-ignore
delete obj[key];
}
});
state.user = obj;
},
resetAuthData() {
// remove local data
localStorage.removeItem(KEY_EXPIRE);
@@ -85,5 +99,5 @@ const authDataSlice = createSlice({
}
});
export const { updateInitialized, setAuthData, resetAuthData, updateToken } = authDataSlice.actions;
export const { updateInitialized, updateLoginUser, setAuthData, resetAuthData, updateToken } = authDataSlice.actions;
export default authDataSlice.reducer;
+9 -1
View File
@@ -16,10 +16,11 @@ import {
updateMute
} from "../../../app/slices/footprint";
import { updateUsersByLogs, updateUsersStatus } from "../../../app/slices/users";
import { resetAuthData } from "../../../app/slices/auth.data";
import { resetAuthData, updateLoginUser } from "../../../app/slices/auth.data";
import chatMessageHandler from "./chat.handler";
import store, { useAppDispatch, useAppSelector } from "../../../app/store";
import { ServerEvent, UsersStateEvent } from "../../../types/sse";
import { isNull, omitBy } from "lodash";
const getQueryString = (params: { [key: string]: string }) => {
const sp = new URLSearchParams();
@@ -130,6 +131,13 @@ export default function useStreaming() {
const { logs } = data;
console.info("sse users change logs", logs);
dispatch(updateUsersByLogs(logs));
// 特殊处理当前登录用户的更新
logs.forEach((log) => {
const { uid, action, log_id, ...rest } = log;
if (uid === loginUid && action === 'update') {
dispatch(updateLoginUser(omitBy(rest, isNull)));
}
});
}
break;
case "user_settings":
@@ -157,6 +157,9 @@ const AdminAccount: FC<Props> = ({ serverName, nextStep }) => {
} else if (password === "") {
toast.error("Please enter admin password!");
return;
} else if (password.length < 6) {
toast.error("Password length greater than 6!");
return;
} else if (password !== confirm) {
toast.error("Two passwords do not match!");
return;
+4
View File
@@ -55,6 +55,10 @@ export default function Reg() {
const handleReg = async (evt: FormEvent<HTMLFormElement>) => {
evt.preventDefault();
const { email, password, confirmPassword } = input;
if (password.length < 6) {
toast.error("Password greater than 6!");
return;
}
if (password !== confirmPassword) {
toast.error("Not Same Password!");
return;