Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 71cbca5

Browse files
authored
Merge pull request #5026 from withspectrum/3.1.4
3.1.4
2 parents 182499b + ea8b285 commit 71cbca5

File tree

28 files changed

+207
-71
lines changed

28 files changed

+207
-71
lines changed

api/apollo-server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class ProtectedApolloServer extends ApolloServer {
4646
}
4747

4848
let connections = 0;
49+
50+
setInterval(() => {
51+
statsd.gauge('websocket.connections.count', connections);
52+
}, 5000);
53+
4954
const server = new ProtectedApolloServer({
5055
schema,
5156
formatError: createErrorFormatter(),
@@ -78,15 +83,15 @@ const server = new ProtectedApolloServer({
7883
subscriptions: {
7984
path: '/websocket',
8085
onDisconnect: rawSocket => {
81-
statsd.gauge('ws.connections', (connections -= 1));
86+
connections--;
8287
return getUserIdFromReq(rawSocket.upgradeReq)
8388
.then(id => id && setUserOnline(id, false))
8489
.catch(err => {
8590
console.error(err);
8691
});
8792
},
8893
onConnect: (connectionParams, rawSocket) => {
89-
statsd.gauge('ws.connections', (connections += 1));
94+
connections++;
9095
return getUserIdFromReq(rawSocket.upgradeReq)
9196
.then(id => (id ? setUserOnline(id, true) : null))
9297
.then(user => {

api/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"engines": {
3-
"node": "^10.0.0"
4-
},
52
"dependencies": {
63
"algoliasearch": "^3.32.1",
74
"apollo-local-query": "^0.3.1",
@@ -109,7 +106,7 @@
109106
"react-router": "^4.0.0-beta.7",
110107
"react-router-dom": "^4.0.0-beta.7",
111108
"react-textarea-autosize": "^4.0.5",
112-
"react-transition-group": "^2.7.1",
109+
"react-transition-group": "^2.8.0",
113110
"react-trend": "^1.2.4",
114111
"recompose": "^0.23.1",
115112
"redis-tag-cache": "^1.2.1",
@@ -142,4 +139,4 @@
142139
"scripts": {
143140
"start": "NODE_ENV=production node main.js"
144141
}
145-
}
142+
}

api/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8072,10 +8072,10 @@ react-textarea-autosize@^4.0.5:
80728072
dependencies:
80738073
prop-types "^15.5.8"
80748074

8075-
react-transition-group@^2.7.1:
8076-
version "2.7.1"
8077-
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-2.7.1.tgz#1fe6d54e811e8f9dfd329aa836b39d9cd16587cb"
8078-
integrity sha512-b0VJTzNRnXxRpCuxng6QJbAzmmrhBn1BZJfPPnHbH2PIo8msdkajqwtfdyGm/OypPXZNfAHKEqeN15wjMXrRJQ==
8075+
react-transition-group@^2.8.0:
8076+
version "2.8.0"
8077+
resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-2.8.0.tgz#d6d8f635d81a0955b67348be5d017cff77d6c75f"
8078+
integrity sha512-So23a1MPn8CGoW5WNU4l0tLiVkOFmeXSS1K4Roe+dxxqqHvI/2XBmj76jx+u96LHnQddWG7LX8QovPAainSmWQ==
80798079
dependencies:
80808080
dom-helpers "^3.3.1"
80818081
loose-envify "^1.4.0"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Spectrum",
3-
"version": "3.1.3",
3+
"version": "3.1.4",
44
"license": "BSD-3-Clause",
55
"devDependencies": {
66
"@babel/preset-flow": "^7.0.0",

shared/generate-meta-info.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function generateMetaInfo(input /*: Input */) /*: Meta */ {
9090
switch (type) {
9191
case 'explore': {
9292
return {
93-
title: 'Explore · Spectrum',
93+
title: 'Explore',
9494
description: 'Explore some of the communities on Spectrum',
9595
};
9696
}
@@ -107,13 +107,13 @@ function generateMetaInfo(input /*: Input */) /*: Meta */ {
107107
? toPlainText(JSON.parse(data.body))
108108
: data.body);
109109
return setDefault({
110-
title: data && data.title + ' · ' + data.communityName + ' community',
110+
title: data && data.title + ' · ' + data.communityName,
111111
description: body,
112112
});
113113
}
114114
case 'user': {
115115
return setDefault({
116-
title: data && data.name + ' (@' + data.username + ')',
116+
title: data && data.name + ' · @' + data.username,
117117
description: data && data.description,
118118
});
119119
}
@@ -139,6 +139,12 @@ function generateMetaInfo(input /*: Input */) /*: Meta */ {
139139
description: data && data.description,
140140
});
141141
}
142+
case 'notifications': {
143+
return setDefault({
144+
title: 'Notifications',
145+
description: 'Notifications on Spectrum',
146+
});
147+
}
142148
default: {
143149
return DEFAULT_META;
144150
}

src/components/composer/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import uploadImage, {
1616
type UploadImageInput,
1717
type UploadImageType,
1818
} from 'shared/graphql/mutations/uploadImage';
19+
import Head from 'src/components/head';
1920
import { TextButton } from 'src/components/button';
2021
import { PrimaryButton } from 'src/components/button';
2122
import Tooltip from 'src/components/tooltip';
@@ -481,6 +482,7 @@ class ComposerWithData extends React.Component<Props, State> {
481482

482483
return (
483484
<Wrapper data-cy="thread-composer-wrapper">
485+
<Head title={'New post'} description={'Write a new post'} />
484486
<Overlay
485487
isModal={isModal}
486488
onClick={this.discardDraft}

src/components/entities/profileCards/community.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { CommunityActions } from './components/communityActions';
66
import { CommunityMeta } from './components/communityMeta';
77
import { ProfileContainer, CoverPhoto, ProfileAvatarContainer } from './style';
88
import type { CommunityInfoType } from 'shared/graphql/fragments/community/communityInfo';
9-
import type { CommunityMetaDataType } from 'shared/graphql/fragments/community/communityMetaData';
109

1110
type Props = {
1211
community: CommunityInfoType,

src/components/entities/profileCards/components/communityMeta.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// @flow
22
import React from 'react';
33
import { Link } from 'react-router-dom';
4-
import type { CommunityInfoType } from 'shared/graphql/fragments/community/communityInfo';
5-
import type { CommunityMetaDataType } from 'shared/graphql/fragments/community/communityMetaData';
64
import renderTextWithLinks from 'src/helpers/render-text-with-markdown-links';
75
import addProtocolToString from 'shared/normalize-url';
86
import Icon from 'src/components/icon';

src/components/entities/profileCards/style.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ export const Description = styled.p`
100100
line-height: 1.4;
101101
color: ${theme.text.secondary};
102102
word-break: break-word;
103+
104+
a {
105+
color: ${theme.text.default};
106+
font-weight: 500;
107+
108+
&:hover {
109+
text-decoration: underline;
110+
}
111+
}
103112
`;
104113

105114
export const MetaLinksContainer = styled.div`

src/components/titlebar/actions.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ export const MobileCommunityAction = (props: CommunityProps) => {
2727

2828
if (isMember) {
2929
return (
30-
<WhiteIconButton
30+
<OutlineButton
31+
size={'small'}
3132
to={{
3233
pathname,
3334
search,
3435
}}
3536
>
36-
<Icon glyph={'post'} size={32} />
37-
</WhiteIconButton>
37+
New post
38+
</OutlineButton>
3839
);
3940
}
4041

@@ -64,14 +65,15 @@ export const MobileChannelAction = (props: ChannelProps) => {
6465

6566
if (isMember) {
6667
return (
67-
<WhiteIconButton
68+
<OutlineButton
69+
size={'small'}
6870
to={{
6971
pathname,
7072
search,
7173
}}
7274
>
73-
<Icon glyph={'post'} size={32} />
74-
</WhiteIconButton>
75+
New post
76+
</OutlineButton>
7577
);
7678
}
7779

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
// @flow
22
import * as React from 'react';
33
import replace from 'string-replace-to-array';
4+
import { Link } from 'react-router-dom';
45
const MARKDOWN_LINK = /(?:\[(.*?)\]\((.*?)\))/g;
6+
import { SPECTRUM_URLS } from 'shared/regexps';
57

68
export default (text: string) => {
7-
return replace(text, MARKDOWN_LINK, (fullLink, text, url) => (
8-
<a href={url} target="_blank" rel="noopener noreferrer" key={url}>
9-
{text}
10-
</a>
11-
));
9+
return replace(text, MARKDOWN_LINK, (fullLink, text, url) => {
10+
const regexp = new RegExp(SPECTRUM_URLS, 'ig');
11+
const match = regexp.exec(url);
12+
13+
if (match && match[0] && match[1]) return <Link to={match[1]}>{text}</Link>;
14+
15+
return (
16+
<a href={url} target="_blank" rel="noopener noreferrer" key={url}>
17+
{text}
18+
</a>
19+
);
20+
});
1221
};

src/views/channel/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ class ChannelView extends React.Component<Props> {
9898

9999
componentDidUpdate(prevProps) {
100100
const { dispatch } = this.props;
101+
if (!prevProps.data.channel && this.props.data.channel) {
102+
const { channel } = this.props.data;
103+
dispatch(
104+
setTitlebarProps({
105+
title: `# ${channel.name}`,
106+
titleIcon: (
107+
<CommunityAvatar
108+
isClickable={false}
109+
community={channel.community}
110+
size={24}
111+
/>
112+
),
113+
rightAction: <MobileChannelAction channel={channel} />,
114+
})
115+
);
116+
}
101117

102118
if (
103119
this.props.data.channel &&

src/views/channelSettings/index.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { connect } from 'react-redux';
66
import { getChannelByMatch } from 'shared/graphql/queries/channel/getChannel';
77
import type { GetChannelType } from 'shared/graphql/queries/channel/getChannel';
88
import { addToastWithTimeout } from 'src/actions/toasts';
9+
import Head from 'src/components/head';
910
import { Upsell404Channel } from 'src/components/upsell';
1011
import viewNetworkHandler from 'src/components/viewNetworkHandler';
1112
import togglePendingUserInChannelMutation from 'shared/graphql/mutations/channel/toggleChannelPendingUser';
@@ -185,17 +186,25 @@ class ChannelSettings extends React.Component<Props> {
185186
};
186187

187188
return (
188-
<ViewGrid>
189-
<View>
190-
<Header
191-
subheading={subheading}
192-
heading={`${channel.name} Settings ${
193-
channel.isArchived ? '(Archived)' : ''
194-
}`}
195-
/>
196-
<ActiveView />
197-
</View>
198-
</ViewGrid>
189+
<React.Fragment>
190+
<Head
191+
title={`${channel.name} settings`}
192+
description={`Settings for the ${channel.name} channel in ${
193+
channel.community.name
194+
}`}
195+
/>
196+
<ViewGrid>
197+
<View>
198+
<Header
199+
subheading={subheading}
200+
heading={`${channel.name} Settings ${
201+
channel.isArchived ? '(Archived)' : ''
202+
}`}
203+
/>
204+
<ActiveView />
205+
</View>
206+
</ViewGrid>
207+
</React.Fragment>
199208
);
200209
}
201210

src/views/communitySettings/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,8 @@ class CommunitySettings extends React.Component<Props> {
9999
community,
100100
};
101101

102-
const activeItem = subnavItems.find(
103-
({ activeLabel }) => activeLabel === activeTab
104-
);
105-
let title = community.name;
106-
if (activeItem && activeItem.label !== 'Settings') {
107-
title += ` ${activeItem.label} Settings`;
108-
} else {
109-
title += ' Settings';
110-
}
102+
let title = community.name + ' settings';
103+
111104
return (
112105
<React.Fragment>
113106
<Head title={title} />

src/views/directMessages/components/header.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ const Header = ({ thread, currentUser }) => {
1616
);
1717

1818
// don't show the header in a 1:1 dm because we already have the titlebar
19-
if (trimmedUsers.length === 1) return null;
19+
if (trimmedUsers.length === 1) {
20+
return (
21+
<Head
22+
title={`Conversation with ${trimmedUsers[0].name}`}
23+
description={`Conversation with ${trimmedUsers[0].name}`}
24+
/>
25+
);
26+
}
2027

2128
const photos = trimmedUsers.map(user => (
2229
<PhotoWrapper key={user.id}>

src/views/directMessages/components/threadsList.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ class ThreadsList extends React.Component<Props, State> {
140140

141141
if (!dmDataExists && dmData.loading) {
142142
return (
143-
<div>
143+
<ThreadsListScrollContainer>
144+
<DesktopTitlebar title={'Messages'} />
144145
<LoadingDM />
145146
<LoadingDM />
146147
<LoadingDM />
@@ -152,7 +153,7 @@ class ThreadsList extends React.Component<Props, State> {
152153
<LoadingDM />
153154
<LoadingDM />
154155
<LoadingDM />
155-
</div>
156+
</ThreadsListScrollContainer>
156157
);
157158
}
158159

src/views/directMessages/containers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import { connect } from 'react-redux';
44
import type { Dispatch } from 'redux';
55
import type { Match } from 'react-router';
6+
import Head from 'src/components/head';
67
import ThreadsList from '../components/threadsList';
78
import ExistingThread from './existingThread';
89
import { PrimaryOutlineButton } from 'src/components/button';
@@ -76,6 +77,7 @@ class DirectMessages extends React.Component<Props, State> {
7677
<ExistingThread id={activeThreadId} match={match} />
7778
) : (
7879
<NoCommunitySelected>
80+
<Head title={'Messages'} />
7981
<div>
8082
<NoCommunityHeading>
8183
No conversation selected

src/views/navigation/communityList.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useEffect } from 'react';
33
import compose from 'recompose/compose';
44
import { Route, type History } from 'react-router-dom';
55
import Tooltip from 'src/components/tooltip';
6+
import { MIN_WIDTH_TO_EXPAND_NAVIGATION } from 'src/components/layout';
67
import viewNetworkHandler from 'src/components/viewNetworkHandler';
78
import { ErrorBoundary } from 'src/components/error';
89
import {
@@ -40,8 +41,15 @@ const CommunityListItem = props => {
4041

4142
const appControlSymbol = '⌘';
4243

44+
const isWideViewport =
45+
window && window.innerWidth > MIN_WIDTH_TO_EXPAND_NAVIGATION;
46+
4347
return (
44-
<Tooltip content={community.name} placement={'left'}>
48+
<Tooltip
49+
content={community.name}
50+
placement={'left'}
51+
isEnabled={!isWideViewport}
52+
>
4553
<AvatarGrid isActive={isActive}>
4654
<AvatarLink
4755
to={`/${community.slug}?tab=posts`}

0 commit comments

Comments
 (0)