mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-07 05:32:35 +00:00
chore: update ts definition generator
This commit is contained in:
@ -1,20 +1,41 @@
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Outlet, useNavigate } from "react-router-dom";
|
||||
import { UserSetting_Locale } from "@/types/proto/api/v2/user_setting_service";
|
||||
import Header from "../components/Header";
|
||||
import useUserStore from "../stores/v1/user";
|
||||
|
||||
const Root: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const currentUser = useUserStore().getCurrentUser();
|
||||
const { i18n } = useTranslation();
|
||||
const userStore = useUserStore();
|
||||
const currentUser = userStore.getCurrentUser();
|
||||
const currentUserSetting = userStore.getCurrentUserSetting();
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUser) {
|
||||
navigate("/auth", {
|
||||
replace: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare user setting.
|
||||
userStore.fetchUserSetting(currentUser.id);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUserSetting) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentUserSetting.locale === UserSetting_Locale.LOCALE_EN) {
|
||||
i18n.changeLanguage("en");
|
||||
} else if (currentUserSetting.locale === UserSetting_Locale.LOCALE_ZH) {
|
||||
i18n.changeLanguage("zh");
|
||||
}
|
||||
}, [currentUserSetting]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{currentUser && (
|
||||
|
Reference in New Issue
Block a user