mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: fix current user store
This commit is contained in:
@ -7,6 +7,7 @@ import * as api from "@/helpers/api";
|
|||||||
import { absolutifyLink } from "@/helpers/utils";
|
import { absolutifyLink } from "@/helpers/utils";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { useUserStore } from "@/store/module";
|
import { useUserStore } from "@/store/module";
|
||||||
|
import { useUserV1Store } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
@ -19,6 +20,7 @@ const AuthCallback = () => {
|
|||||||
const navigateTo = useNavigateTo();
|
const navigateTo = useNavigateTo();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const userV1Store = useUserV1Store();
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
loading: true,
|
loading: true,
|
||||||
errorMessage: "",
|
errorMessage: "",
|
||||||
@ -42,6 +44,7 @@ const AuthCallback = () => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
userStore.setCurrentUser(user);
|
userStore.setCurrentUser(user);
|
||||||
await userStore.fetchCurrentUser();
|
await userStore.fetchCurrentUser();
|
||||||
|
await userV1Store.getOrFetchUserByUsername(user.username);
|
||||||
navigateTo("/");
|
navigateTo("/");
|
||||||
} else {
|
} else {
|
||||||
toast.error(t("message.login-failed"));
|
toast.error(t("message.login-failed"));
|
||||||
|
@ -9,6 +9,7 @@ import { absolutifyLink } from "@/helpers/utils";
|
|||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { useGlobalStore, useUserStore } from "@/store/module";
|
import { useGlobalStore, useUserStore } from "@/store/module";
|
||||||
|
import { useUserV1Store } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
const SignIn = () => {
|
const SignIn = () => {
|
||||||
@ -16,6 +17,7 @@ const SignIn = () => {
|
|||||||
const navigateTo = useNavigateTo();
|
const navigateTo = useNavigateTo();
|
||||||
const globalStore = useGlobalStore();
|
const globalStore = useGlobalStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const userV1Store = useUserV1Store();
|
||||||
const actionBtnLoadingState = useLoading(false);
|
const actionBtnLoadingState = useLoading(false);
|
||||||
const { appearance, locale, systemStatus } = globalStore.state;
|
const { appearance, locale, systemStatus } = globalStore.state;
|
||||||
const mode = systemStatus.profile.mode;
|
const mode = systemStatus.profile.mode;
|
||||||
@ -78,6 +80,7 @@ const SignIn = () => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
userStore.setCurrentUser(user);
|
userStore.setCurrentUser(user);
|
||||||
await userStore.fetchCurrentUser();
|
await userStore.fetchCurrentUser();
|
||||||
|
await userV1Store.getOrFetchUserByUsername(user.username);
|
||||||
navigateTo("/");
|
navigateTo("/");
|
||||||
} else {
|
} else {
|
||||||
toast.error(t("message.login-failed"));
|
toast.error(t("message.login-failed"));
|
||||||
|
@ -8,6 +8,7 @@ import * as api from "@/helpers/api";
|
|||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { useGlobalStore, useUserStore } from "@/store/module";
|
import { useGlobalStore, useUserStore } from "@/store/module";
|
||||||
|
import { useUserV1Store } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
const SignUp = () => {
|
const SignUp = () => {
|
||||||
@ -15,6 +16,7 @@ const SignUp = () => {
|
|||||||
const navigateTo = useNavigateTo();
|
const navigateTo = useNavigateTo();
|
||||||
const globalStore = useGlobalStore();
|
const globalStore = useGlobalStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const userV1Store = useUserV1Store();
|
||||||
const actionBtnLoadingState = useLoading(false);
|
const actionBtnLoadingState = useLoading(false);
|
||||||
const { appearance, locale, systemStatus } = globalStore.state;
|
const { appearance, locale, systemStatus } = globalStore.state;
|
||||||
const [username, setUsername] = useState("");
|
const [username, setUsername] = useState("");
|
||||||
@ -58,6 +60,7 @@ const SignUp = () => {
|
|||||||
if (user) {
|
if (user) {
|
||||||
userStore.setCurrentUser(user);
|
userStore.setCurrentUser(user);
|
||||||
await userStore.fetchCurrentUser();
|
await userStore.fetchCurrentUser();
|
||||||
|
await userV1Store.getOrFetchUserByUsername(user.username);
|
||||||
navigateTo("/");
|
navigateTo("/");
|
||||||
} else {
|
} else {
|
||||||
toast.error(t("message.signup-failed"));
|
toast.error(t("message.signup-failed"));
|
||||||
|
Reference in New Issue
Block a user