mirror of
https://github.com/usememos/memos.git
synced 2025-12-11 14:46:03 +08:00
fix: dialog state
This commit is contained in:
parent
6119a4b965
commit
f09897e4b6
4 changed files with 24 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
|
|
@ -20,10 +20,6 @@ function ChangeMemberPasswordDialog({ open, onOpenChange, user, onSuccess }: Pro
|
|||
const [newPassword, setNewPassword] = useState("");
|
||||
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
// do nth
|
||||
}, []);
|
||||
|
||||
const handleCloseBtnClick = () => {
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
|
|||
setOAuth2Scopes(oauth2Config.scopes.join(" "));
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
}, [identityProvider]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isCreating) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
|
|
@ -30,6 +30,18 @@ function CreateShortcutDialog({ open, onOpenChange, shortcut: initialShortcut, o
|
|||
const requestState = useLoading(false);
|
||||
const isCreating = !initialShortcut;
|
||||
|
||||
useEffect(() => {
|
||||
if (initialShortcut) {
|
||||
setShortcut({
|
||||
name: initialShortcut.name,
|
||||
title: initialShortcut.title,
|
||||
filter: initialShortcut.filter,
|
||||
});
|
||||
} else {
|
||||
setShortcut({ name: "", title: "", filter: "" });
|
||||
}
|
||||
}, [initialShortcut]);
|
||||
|
||||
const onShortcutTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setShortcut({ ...shortcut, title: e.target.value });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
|
|
@ -23,6 +23,14 @@ function CreateUserDialog({ open, onOpenChange, user: initialUser, onSuccess }:
|
|||
const requestState = useLoading(false);
|
||||
const isCreating = !initialUser;
|
||||
|
||||
useEffect(() => {
|
||||
if (initialUser) {
|
||||
setUser(User.fromPartial(initialUser));
|
||||
} else {
|
||||
setUser(User.fromPartial({}));
|
||||
}
|
||||
}, [initialUser]);
|
||||
|
||||
const setPartialUser = (state: Partial<User>) => {
|
||||
setUser({
|
||||
...user,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue