@@ -11,22 +11,22 @@ import './Home.css'
11
11
12
12
export default class HomeComponent extends Component {
13
13
constructor ( props ) {
14
- super ( props ) ;
15
- this . urlParams = new URLSearchParams ( window . location . search ) ;
16
- this . state = {
17
- links : [ ] ,
18
- usedSettings : this . urlParams . get ( 'customUrl' ) ? [ 'custom' ] : [ ] ,
19
- customID : this . urlParams . get ( 'customUrl' ) ? this . urlParams . get ( 'customUrl' ) : '' ,
20
- showCustomIDError : false ,
21
- expiration : null ,
22
- displayURL : window . location . origin
23
- }
14
+ super ( props ) ;
15
+ this . urlParams = new URLSearchParams ( window . location . search ) ;
16
+ this . state = {
17
+ links : [ ] ,
18
+ usedSettings : this . urlParams . get ( 'customUrl' ) ? [ 'custom' ] : [ ] ,
19
+ customID : this . urlParams . get ( 'customUrl' ) ? this . urlParams . get ( 'customUrl' ) : '' ,
20
+ showCustomIDError : false ,
21
+ expiration : null ,
22
+ displayURL : window . location . origin
23
+ }
24
24
}
25
25
handleURLChange = ( e , { value } ) => this . url = value
26
26
handlePasswordChange = ( e , { value } ) => this . password = value
27
27
handleCustomExpirationChange = expire => this . setState ( { expiration : expire } )
28
28
handleCustomIDChange = ( e , { value } ) => {
29
- this . setState ( { customID : value } )
29
+ this . setState ( { customID : value } )
30
30
util . lookupEntry ( value , ( ) => this . setState ( { showCustomIDError : true } ) , ( ) => this . setState ( { showCustomIDError : false } ) )
31
31
}
32
32
onSettingsChange = ( e , { value } ) => {
@@ -36,9 +36,8 @@ export default class HomeComponent extends Component {
36
36
37
37
componentDidMount ( ) {
38
38
this . urlInput . focus ( )
39
- fetch ( "/displayurl" )
40
- . then ( response => response . json ( ) )
41
- . then ( data => this . setState ( { displayURL : data } ) ) ;
39
+ util . getDisplayURL ( )
40
+ . then ( displayURL => this . setState ( { displayURL } ) ) ;
42
41
}
43
42
handleURLSubmit = ( ) => {
44
43
if ( ! this . state . showCustomIDError ) {
@@ -71,7 +70,7 @@ export default class HomeComponent extends Component {
71
70
{ this . urlParams . get ( "customUrl" ) ? (
72
71
< Header size = 'medium' > I don't have a link named < em > "{ this . urlParams . get ( "customUrl" ) } "</ em > in my database, would
73
72
you like to create one?</ Header >
74
- ) :
73
+ ) :
75
74
< Header size = 'huge' > Simplify your links</ Header >
76
75
}
77
76
< Form onSubmit = { this . handleURLSubmit } autoComplete = "off" >
@@ -91,7 +90,7 @@ export default class HomeComponent extends Component {
91
90
</ MediaQuery >
92
91
< Form . Group style = { { marginBottom : "1rem" } } >
93
92
{ usedSettings . includes ( "custom" ) && < Form . Field error = { showCustomIDError } width = { 16 } >
94
- < Input label = { this . state . displayURL + "/" } onChange = { this . handleCustomIDChange } placeholder = 'my-shortened-url' value = { this . state . customID } />
93
+ < Input label = { this . state . displayURL + "/" } onChange = { this . handleCustomIDChange } placeholder = 'my-shortened-url' value = { this . state . customID } />
95
94
</ Form . Field > }
96
95
</ Form . Group >
97
96
< Form . Group widths = "equal" >
0 commit comments