Skip to content

Commit 8ca2c57

Browse files
committed
Fix no last_name thanks to beta tester 🙌
1 parent 47b682f commit 8ca2c57

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

src/components/Main/TodoBox.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { v4 } from "uuid";
77
import { Icon } from "react-icons-kit";
88
import { checkmark } from "react-icons-kit/icomoon/checkmark";
99
import { cross } from "react-icons-kit/icomoon/cross";
10+
import { shell } from "electron";
1011

1112
import { DeleteTodo } from "./DeleteTodo";
1213

@@ -39,13 +40,33 @@ const StatusIcon = styled(Icon)`
3940
align-self: flex-start;
4041
`;
4142

43+
const Btn = styled.button`
44+
font-size: 1.6rem;
45+
font-family: ${props => props.theme.global.fontFamily};
46+
font-weight: 300;
47+
border: none;
48+
color: ${props => props.theme.hashtag.textColor};
49+
background: ${props => props.theme.hashtag.bgColor};
50+
border-bottom: 0.1rem solid ${props => props.theme.hashtag.underlineColor};
51+
padding: 0.3rem;
52+
`;
53+
4254
class TodoBoxContainer extends React.Component {
4355
_getHashtag = (body, hashtag) => {
4456
return reactStringReplace(body, `#${hashtag}`, (match, i) => (
4557
<Hashtag key={v4()}>{match}</Hashtag>
4658
));
4759
};
4860

61+
_getLink = body => {
62+
const urlRegex = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})/;
63+
return reactStringReplace(body, urlRegex, (match, i) => (
64+
<Btn key={v4()} onClick={() => shell.openExternal(match)}>
65+
{match}
66+
</Btn>
67+
));
68+
};
69+
4970
render() {
5071
const { status, todo, hashtag, productId, theme } = this.props;
5172
const completed_at = completed ? new Date().toISOString() : null;
@@ -140,7 +161,7 @@ class TodoBoxContainer extends React.Component {
140161
size={16}
141162
/>
142163
<Todo>
143-
{this._getHashtag(todo.body, hashtag)}
164+
{this._getLink(this._getHashtag(todo.body, hashtag))}
144165
<DeleteTodo
145166
id={todo.id}
146167
productId={productId}

src/graphql/queries/GET_USER.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ export const GET_USER = gql`
44
query GetUser {
55
viewer {
66
id
7-
first_name
8-
last_name
9-
username
10-
url
117
}
128
}
139
`;

src/pages/Token.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import React from "react";
22
import { ApolloConsumer } from "react-apollo";
33
import { Redirect } from "react-router-dom";
44
import styled from "react-emotion";
5+
import reactStringReplace from "react-string-replace";
56
import { withTheme } from "emotion-theming";
67
import Loading from "react-loading";
8+
import { shell } from "electron";
9+
import { v4 } from "uuid";
710

811
import { CREATE_TODO } from "../graphql/mutation/CREATE_TODO";
912
import { DELETE_TODO } from "../graphql/mutation/DELETE_TODO";
@@ -58,25 +61,38 @@ const Error = styled.div`
5861
font-size: 2rem;
5962
`;
6063

64+
const Btn = styled.button`
65+
font-size: 1.8rem;
66+
padding: 0;
67+
border: none;
68+
text-decoration: none;
69+
color: red;
70+
border-bottom: 0.1rem solid red;
71+
`;
72+
6173
class TokenContainer extends React.Component {
6274
state = {
6375
token: "",
6476
loading: false,
65-
error: false,
77+
error: "Please find your token at https://wip.chat/api",
6678
};
6779

6880
_onTokenChange = e => {
6981
this.setState({ token: e.target.value });
7082
};
7183

84+
_getLink = body => {
85+
const urlRegex = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})/;
86+
return reactStringReplace(body, urlRegex, (match, i) => (
87+
<Btn key={v4()} onClick={() => shell.openExternal(match)}>
88+
{match}
89+
</Btn>
90+
));
91+
};
92+
7293
_onSave = async client => {
7394
const { token } = this.state;
74-
if (token === "") {
75-
this.setState({
76-
error: "Please enter your token found at https://wip.chat/api",
77-
});
78-
return;
79-
}
95+
if (token === "") return;
8096
state.set({ token });
8197
this.setState({ error: false, loading: true });
8298
const body =
@@ -124,7 +140,7 @@ class TokenContainer extends React.Component {
124140
/>
125141
<Button onClick={() => this._onSave(client)}>Save Token</Button>
126142
{loading && <Loading color={theme.loading.color} type="bars" />}
127-
{error && <Error>{error}</Error>}
143+
{error && <Error>{this._getLink(error)}</Error>}
128144
</Wrapper>
129145
</Container>
130146
)}

0 commit comments

Comments
 (0)