@@ -11,22 +11,22 @@ import './Home.css'
1111
1212export default class HomeComponent extends Component {
1313 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+ }
2424 }
2525 handleURLChange = ( e , { value } ) => this . url = value
2626 handlePasswordChange = ( e , { value } ) => this . password = value
2727 handleCustomExpirationChange = expire => this . setState ( { expiration : expire } )
2828 handleCustomIDChange = ( e , { value } ) => {
29- this . setState ( { customID : value } )
29+ this . setState ( { customID : value } )
3030 util . lookupEntry ( value , ( ) => this . setState ( { showCustomIDError : true } ) , ( ) => this . setState ( { showCustomIDError : false } ) )
3131 }
3232 onSettingsChange = ( e , { value } ) => {
@@ -36,9 +36,8 @@ export default class HomeComponent extends Component {
3636
3737 componentDidMount ( ) {
3838 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 } ) ) ;
4241 }
4342 handleURLSubmit = ( ) => {
4443 if ( ! this . state . showCustomIDError ) {
@@ -71,7 +70,7 @@ export default class HomeComponent extends Component {
7170 { this . urlParams . get ( "customUrl" ) ? (
7271 < Header size = 'medium' > I don't have a link named < em > "{ this . urlParams . get ( "customUrl" ) } "</ em > in my database, would
7372 you like to create one?</ Header >
74- ) :
73+ ) :
7574 < Header size = 'huge' > Simplify your links</ Header >
7675 }
7776 < Form onSubmit = { this . handleURLSubmit } autoComplete = "off" >
@@ -91,7 +90,7 @@ export default class HomeComponent extends Component {
9190 </ MediaQuery >
9291 < Form . Group style = { { marginBottom : "1rem" } } >
9392 { 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 } />
9594 </ Form . Field > }
9695 </ Form . Group >
9796 < Form . Group widths = "equal" >
0 commit comments