Merge branch 'Privoce:main' into feat/add-Japanese-support
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<center>
|
||||
|
||||
[](https://github.com/privoce/vocechat-web/issues)
|
||||
  
|
||||
   
|
||||
|
||||
</center>
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"title": "Language",
|
||||
"desc": "Setting the language",
|
||||
"en": "English",
|
||||
"zh": "中文",
|
||||
"zh": "Chinese",
|
||||
"jp": "Japanese"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user