diff --git a/src/assets/stylesheets/link.scss b/src/assets/stylesheets/link.scss index b94325c5039062d7848a4d254df9d27b88a7ceb4..accfb2be29a363c1022e558a31a9993d6acf92b8 100644 --- a/src/assets/stylesheets/link.scss +++ b/src/assets/stylesheets/link.scss @@ -169,7 +169,7 @@ a { background: transparent; color: white; margin: 0; - font-size: 64pt; + font-size: 52pt; border: 0; width: 295px; letter-spacing: 0.08em; diff --git a/src/link.js b/src/link.js index 401fe54d9b8b9bd91df1c2140257710502a23add..908f7f64d4fadd8f906b09a7874e8e882c93b81d 100644 --- a/src/link.js +++ b/src/link.js @@ -3,18 +3,7 @@ import React from "react"; import ReactDOM from "react-dom"; import registerTelemetry from "./telemetry"; import LinkRoot from "./react-components/link-root"; -import LinkChannel from "./utils/link-channel"; -import { connectToReticulum } from "./utils/phoenix-utils"; -import Store from "./storage/store"; registerTelemetry(); -const socket = connectToReticulum(); -const store = new Store(); -store.init(); - -const linkChannel = new LinkChannel(store); - -linkChannel.setSocket(socket); - -ReactDOM.render(<LinkRoot store={store} linkChannel={linkChannel} />, document.getElementById("link-root")); +ReactDOM.render(<LinkRoot />, document.getElementById("link-root")); diff --git a/src/react-components/link-root.js b/src/react-components/link-root.js index 84b7101637357253da095a0c69bd0f20382318e4..f9aab014bb2f0ba5e6779a4c1020d34aa8416f96 100644 --- a/src/react-components/link-root.js +++ b/src/react-components/link-root.js @@ -8,16 +8,14 @@ import classNames from "classnames"; import styles from "../assets/stylesheets/link.scss"; import { disableiOSZoom } from "../utils/disable-ios-zoom"; -const MAX_DIGITS = 4; +const MAX_DIGITS = 6; addLocaleData([...en]); disableiOSZoom(); class LinkRoot extends Component { static propTypes = { - intl: PropTypes.object, - store: PropTypes.object, - linkChannel: PropTypes.object + intl: PropTypes.object }; state = { @@ -62,30 +60,15 @@ class LinkRoot extends Component { this.setState({ enteredDigits: enteredDigits.substring(0, enteredDigits.length - 1) }); }; - attemptLink = code => { - this.props.linkChannel - .attemptLink(code) - .then(response => { - // If there is a profile from the linked device, copy it over if we don't have one yet. - if (response.profile) { - const { hasChangedName } = this.props.store.state.activity; - - if (!hasChangedName) { - this.props.store.update({ activity: { hasChangedName: true }, profile: response.profile }); - } - } - - if (response.path) { - window.location.href = response.path; - } - }) - .catch(e => { - this.setState({ failedAtLeastOnce: true, enteredDigits: "" }); - - if (!(e instanceof Error && (e.message === "in_use" || e.message === "failed"))) { - throw e; - } - }); + attemptLink = async code => { + const url = "https://hub.link/" + code; + const res = await fetch(url); + + if (res.status >= 400) { + this.setState({ failedAtLeastOnce: true, enteredDigits: "" }); + } else { + document.location = url; + } }; render() { @@ -119,7 +102,7 @@ class LinkRoot extends Component { onChange={ev => { this.setState({ enteredDigits: ev.target.value }); }} - placeholder="- - - -" + placeholder="- - - - - -" /> </div>