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

Commit 31450a3

Browse files
authored
Merge pull request #4991 from withspectrum/3.1.1
3.1.1
2 parents efbe61b + 5ff88d9 commit 31450a3

File tree

69 files changed

+464
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+464
-264
lines changed

Diff for: api/models/thread.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
trackQueue,
77
searchQueue,
88
} from 'shared/bull/queues';
9-
const { parseRange } = require('./utils');
9+
const { parseRange, NEW_DOCUMENTS } = require('./utils');
1010
import { createChangefeed } from 'shared/changefeed-utils';
1111
import { deleteMessagesInThread } from '../models/message';
1212
import { turnOffAllThreadNotifications } from '../models/usersThreads';
@@ -760,12 +760,30 @@ export const decrementReactionCount = (threadId: string) => {
760760
.run();
761761
};
762762

763+
const hasChanged = (field: string) =>
764+
db
765+
.row('old_val')(field)
766+
.ne(db.row('new_val')(field));
767+
763768
const getUpdatedThreadsChangefeed = () =>
764769
db
765770
.table('threads')
766771
.changes({
767772
includeInitial: false,
768-
})('new_val')
773+
})
774+
.filter(
775+
NEW_DOCUMENTS.or(
776+
hasChanged('content')
777+
.or(hasChanged('lastActive'))
778+
.or(hasChanged('channelId'))
779+
.or(hasChanged('communityId'))
780+
.or(hasChanged('creatorId'))
781+
.or(hasChanged('isPublished'))
782+
.or(hasChanged('modifiedAt'))
783+
.or(hasChanged('messageCount'))
784+
.or(hasChanged('reactionCount'))
785+
)
786+
)('new_val')
769787
.run();
770788

771789
export const listenToUpdatedThreads = (cb: Function): Function => {

Diff for: cypress/integration/channel/settings/edit_spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('edit a channel', () => {
2222

2323
it('should edit a channel', () => {
2424
cy.get('[data-cy="channel-overview"]').should('be.visible');
25-
25+
cy.get('[data-cy="channel-members"]').should('be.visible');
2626
cy.get('[data-cy="channel-name-input"]')
2727
.should('be.visible')
2828
.click()

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Spectrum",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"license": "BSD-3-Clause",
55
"devDependencies": {
66
"@babel/preset-flow": "^7.0.0",

Diff for: shared/clients/draft-js/links-decorator/index.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
// @flow
22
import React from 'react';
3+
import { Link } from 'react-router-dom';
34
import createLinksDecorator, {
45
type LinksDecoratorComponentProps,
56
} from './core';
7+
import { SPECTRUM_URLS } from 'shared/regexps';
68

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

Diff for: shared/clients/draft-js/renderer/index.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @flow
22
import React from 'react';
3+
import { Link } from 'react-router-dom';
34
import Highlight, { defaultProps } from 'prism-react-renderer';
45
import { Line, Paragraph, BlockQuote } from 'src/components/message/style';
56
import {
@@ -13,6 +14,7 @@ import { hasStringElements } from '../utils/hasStringElements';
1314
import mentionsDecorator from '../mentions-decorator';
1415
import linksDecorator from '../links-decorator';
1516
import type { Node } from 'react';
17+
import { SPECTRUM_URLS } from 'shared/regexps';
1618
import type { KeyObj, KeysObj, DataObj } from '../message/types';
1719
import type {
1820
EmbedData,
@@ -159,16 +161,23 @@ export const createRenderer = (options: Options) => {
159161
),
160162
},
161163
entities: {
162-
LINK: (children: Array<Node>, data: DataObj, { key }: KeyObj) => (
163-
<a
164-
key={key}
165-
href={data.url || data.href}
166-
target="_blank"
167-
rel="noopener noreferrer"
168-
>
169-
{children}
170-
</a>
171-
),
164+
LINK: (children: Array<Node>, data: DataObj, { key }: KeyObj) => {
165+
const link = data.url || data.href;
166+
167+
if (typeof link !== 'string') {
168+
return (
169+
<a key={key} href={link} target="_blank" rel="noopener noreferrer">
170+
{children}
171+
</a>
172+
);
173+
}
174+
175+
const regexp = new RegExp(SPECTRUM_URLS, 'ig');
176+
const match = regexp.exec(link);
177+
if (match && match[0] && match[1]) {
178+
return <Link to={match[1]}>{children}</Link>;
179+
}
180+
},
172181
IMAGE: (
173182
children: Array<Node>,
174183
data: { src?: string, alt?: string },

Diff for: shared/graphql/mutations/community/createCommunity.js

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import gql from 'graphql-tag';
33
import { graphql } from 'react-apollo';
44
import communityInfoFragment from '../../fragments/community/communityInfo';
5+
import { getCommunityBySlugQuery } from '../../queries/community/getCommunity';
56
import type { CommunityInfoType } from '../../fragments/community/communityInfo';
67

78
export type CreateCommunityType = {
@@ -39,6 +40,16 @@ const createCommunityOptions = {
3940
},
4041
}),
4142
}),
43+
options: {
44+
refetchQueries: result => [
45+
{
46+
query: getCommunityBySlugQuery,
47+
variables: {
48+
slug: result.data.createCommunity.slug,
49+
},
50+
},
51+
],
52+
},
4253
};
4354

4455
export default graphql(createCommunityMutation, createCommunityOptions);

Diff for: shared/graphql/queries/community/getCommunity.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ export const getCommunityByMatchQuery = gql`
7171
`;
7272

7373
const getCommunityByMatchOptions = {
74-
options: ({ match: { params: { communitySlug } } }) => ({
74+
options: ({
75+
match: {
76+
params: { communitySlug },
77+
},
78+
}) => ({
7579
variables: {
7680
slug: communitySlug,
7781
},
82+
fetchPolicy: 'cache-first',
7883
}),
7984
};
8085

Diff for: shared/regexps.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
module.exports.MENTIONS = /\/?\B@[a-z0-9._-]+[a-z0-9_-]/gi;
44
module.exports.URL = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/=]*)/gi;
55
module.exports.RELATIVE_URL = /^\/([^\/].*|$)/g;
6+
module.exports.SPECTRUM_URLS = /(?:(?:https?:\/\/)?|\B)(?:spectrum\.chat|localhost:3000)(\/[A-Za-z0-9\-\._~:\/\?#\[\]@!$&'\(\)\*\+,;\=]*)?/gi;

Diff for: src/components/badges/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styled from 'styled-components';
44
import { Gradient } from 'src/components/globals';
55

66
export const Span = styled.span`
7-
display: inline-flex;
7+
display: inline-block;
88
color: ${theme.text.reverse};
99
background-color: ${theme.text.alt};
1010
text-transform: uppercase;

Diff for: src/components/button/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const StyledButton = styled.button`
3333
line-height: 1.2;
3434
transition: box-shadow 0.2s ease-in-out;
3535
36-
.icon {
36+
.icon:not(:first-child):not(:last-child) {
3737
margin-right: 4px;
3838
}
3939

Diff for: src/components/chatInput/style.js

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export const Input = styled(MentionsInput).attrs({
107107
font-size: 16px;
108108
}
109109
110+
div,
111+
textarea {
112+
line-height: 1.4 !important;
113+
word-break: break-word;
114+
}
115+
110116
&::placeholder {
111117
color: ${props =>
112118
props.networkDisabled

Diff for: src/components/composer/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export const ThreadTitle = {
262262
padding: '0',
263263
outline: 'none',
264264
border: '0',
265-
lineHeight: '1.3',
265+
lineHeight: '1.4',
266266
fontWeight: '600',
267267
boxShadow: 'none',
268268
width: '100%',

Diff for: src/components/composerMini/index.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import type { CommunityInfoType } from 'shared/graphql/fragments/community/commu
2525
import type { History } from 'react-router-dom';
2626
import { DISCARD_DRAFT_MESSAGE } from 'src/components/composer';
2727
import { openModal } from 'src/actions/modals';
28-
import { Container } from './style';
28+
import { Container, BodyContainer } from './style';
2929

3030
type Props = {
3131
community: CommunityInfoType,
@@ -278,23 +278,13 @@ const MiniComposer = ({
278278
{!expanded && <PrimaryButton tabIndex={-1}>Post</PrimaryButton>}
279279
</div>
280280
{expanded && (
281-
<div
282-
css={{
283-
width: '100%',
284-
paddingLeft: '48px',
285-
paddingRight: '8px',
286-
marginTop: '8px',
287-
fontSize: '16px',
288-
display: 'flex',
289-
flexDirection: 'column',
290-
alignItems: 'flex-end',
291-
}}
292-
>
281+
<BodyContainer>
293282
<Dropzone
294283
accept={['image/gif', 'image/jpeg', 'image/png', 'video/mp4']}
295284
disableClick
296285
multiple={false}
297286
onDropAccepted={uploadFiles}
287+
style={{ lineHeight: '1.4' }}
298288
>
299289
{({ getRootProps, getInputProps, isDragActive }) => (
300290
<div
@@ -316,6 +306,7 @@ const MiniComposer = ({
316306
border: `1px solid ${theme.bg.border}`,
317307
borderRadius: '8px',
318308
width: '100%',
309+
lineHeight: '1.4',
319310
input: {
320311
fontSize: '16px',
321312
minHeight: '80px',
@@ -404,7 +395,7 @@ const MiniComposer = ({
404395
</PrimaryButton>
405396
</div>
406397
</div>
407-
</div>
398+
</BodyContainer>
408399
)}
409400
</Container>
410401
);

Diff for: src/components/composerMini/style.js

+17
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,20 @@ export const Container = styled.div`
1515
display: none;
1616
}
1717
`;
18+
19+
export const BodyContainer = styled.div`
20+
width: 100%;
21+
padding-left: 48px;
22+
padding-right: 8px;
23+
margin-top: 8px;
24+
font-size: 16px;
25+
display: flex;
26+
flex-direction: column;
27+
align-items: flex-end;
28+
29+
div,
30+
textarea {
31+
line-height: 1.4 !important;
32+
word-break: break-word;
33+
}
34+
`;

Diff for: src/components/emailInvitationForm/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ class EmailInvitationForm extends React.Component<Props, State> {
419419
onClick={this.sendInvitations}
420420
disabled={hasCustomMessage && customMessageError}
421421
>
422-
Send Invitations
422+
{isLoading ? 'Sending...' : 'Send Invitations'}
423423
</OutlineButton>
424424
</SectionCardFooter>
425425
</div>

0 commit comments

Comments
 (0)