Skip to content

Commit a1fd776

Browse files
committed
Add auto input for token name edit
1 parent 839a13c commit a1fd776

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, { useEffect, useRef } from 'react'
2+
import { Input, InputProps, InputRef } from 'antd'
3+
4+
const AutoFocusInput: React.FC<InputProps> = (props) => {
5+
const inputRef = useRef<InputRef>(null)
6+
7+
useEffect(() => {
8+
setTimeout(() => {
9+
if (inputRef.current === null) {
10+
return
11+
}
12+
inputRef.current.focus()
13+
}, 100)
14+
}, [])
15+
16+
return <Input ref={inputRef} {...props} />
17+
}
18+
19+
export default AutoFocusInput

src/client/me/me.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
DownloadOutlined,
2222
JavaScriptOutlined
2323
} from '@ant-design/icons'
24+
import AutoFocusInput from '../common/auto-focus-input'
2425

2526
interface JsonType {
2627
[key: string]: any
@@ -136,8 +137,9 @@ export default function Me (props: any): JSX.Element {
136137
tokenNameRef.current = name
137138
return (
138139
<div>
139-
<Input
140+
<AutoFocusInput
140141
onChange={onChangeTokenName}
142+
key={Date.now()}
141143
placeholder={t('tokenName')}
142144
defaultValue={name}
143145
autoFocus

src/server/models/user-model.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ export const userSchema = Object.assign({}, adminUserSchema, {
3232
type: String,
3333
default: ''
3434
},
35+
authoredBookIds: {
36+
type: String,
37+
default: ''
38+
},
39+
readBookIds: {
40+
type: String,
41+
default: ''
42+
},
43+
bookshelfIds: {
44+
type: String,
45+
default: ''
46+
},
47+
followingAuthorIds: {
48+
type: String,
49+
default: ''
50+
},
51+
followerIds: {
52+
type: String,
53+
default: ''
54+
},
3555
tokenLimit: {
3656
type: Number,
3757
default: 1

0 commit comments

Comments
 (0)