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

api/models/thread.js

Lines changed: 20 additions & 2 deletions
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 => {

cypress/integration/channel/settings/edit_spec.js

Lines changed: 1 addition & 1 deletion
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()

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.0",
3+
"version": "3.1.1",
44
"license": "BSD-3-Clause",
55
"devDependencies": {
66
"@babel/preset-flow": "^7.0.0",
Lines changed: 15 additions & 5 deletions
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+
});

shared/clients/draft-js/renderer/index.js

Lines changed: 19 additions & 10 deletions
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 },

shared/graphql/mutations/community/createCommunity.js

Lines changed: 11 additions & 0 deletions
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);

shared/graphql/queries/community/getCommunity.js

Lines changed: 6 additions & 1 deletion
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

shared/regexps.js

Lines changed: 1 addition & 0 deletions
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;

src/components/badges/style.js

Lines changed: 1 addition & 1 deletion
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;

src/components/button/style.js

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)