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

Commit e2d8786

Browse files
committed
Merge branch 'alpha' of github.com:withspectrum/spectrum into message-syntax-highlighting
2 parents 8c38f72 + 68ae876 commit e2d8786

File tree

32 files changed

+329
-265
lines changed

32 files changed

+329
-265
lines changed

.circleci/config.yml

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,24 @@ jobs:
8080
root: .
8181
paths: .
8282

83-
# Start db and servers, then run e2e and unit tests
84-
test_web:
83+
build_web:
84+
<<: *js_defaults
85+
steps:
86+
- attach_workspace:
87+
at: ~/spectrum
88+
- run: *setup-and-build-web
89+
- run: *build-api
90+
- persist_to_workspace:
91+
root: .
92+
paths:
93+
- build-api
94+
- build
95+
96+
test_unit:
8597
<<: *defaults
8698
docker:
87-
- image: circleci/node:8-browsers
99+
- image: circleci/node:8
88100
- image: redis:3.2.7
89-
- image: cypress/base:6
90101
- image: rethinkdb:2.3.5
91102
environment:
92103
TERM: xterm
@@ -98,42 +109,40 @@ jobs:
98109
- run:
99110
name: Run Unit Tests
100111
command: yarn run test:ci
101-
- run: *setup-and-build-web
102-
- run: *build-api
112+
113+
114+
# Start db and servers, then run e2e and unit tests
115+
test_e2e:
116+
<<: *defaults
117+
docker:
118+
- image: circleci/node:8-browsers
119+
- image: redis:3.2.7
120+
- image: cypress/base:6
121+
- image: rethinkdb:2.3.5
122+
parallel: true
123+
parallelism: 9
124+
environment:
125+
TERM: xterm
126+
steps:
127+
- attach_workspace:
128+
at: ~/spectrum
129+
- run: yarn run db:migrate
130+
- run: yarn run db:seed
103131
- run: *start-api
104132
- run: *start-web
105133
# Wait for the API and webserver to start
106134
- run: ./node_modules/.bin/wait-on http://localhost:3000 http://localhost:3001
107-
- run:
108-
name: Run Unit Tests
109-
command: yarn run test:ci
110135
- run:
111136
name: Install Cypress
112137
command: yarn run cypress:install
113138
- run:
114139
name: Run E2E Tests
115-
command: test $CYPRESS_RECORD_KEY && yarn run test:e2e -- --record || yarn run test:e2e
116-
- run:
117-
name: Test desktop apps
118-
command: yarn run test:desktop
119-
120-
# deploy_alpha:
121-
# <<: *js_defaults
122-
# docker:
123-
# - image: circleci/node:8-browsers
124-
# steps:
125-
# - attach_workspace:
126-
# at: ~/spectrum
127-
# - run: *build-api
128-
# - run:
129-
# name: Deploy and alias API
130-
# command: |
131-
# cd build-api
132-
# npx now-cd --alias "alpha=api.alpha.spectrum.chat" --team space-program
133-
# cd ..
134-
# - run:
135-
# name: Deploy and alias Hyperion
136-
# command: npx now-cd --alias "alpha=hyperion.alpha.spectrum.chat" --team space-program
140+
command: |
141+
if [ $CYPRESS_RECORD_KEY ]; then
142+
yarn run test:e2e -- --record --parallel
143+
else
144+
yarn run test:e2e
145+
fi
137146
138147
# Run eslint, flow etc.
139148
test_static_js:
@@ -154,20 +163,15 @@ workflows:
154163
test:
155164
jobs:
156165
- checkout_environment
157-
158-
# Testing
159-
- test_web:
166+
- test_unit:
160167
requires:
161168
- checkout_environment
162169
- test_static_js:
163170
requires:
164171
- checkout_environment
165-
166-
# Deployment
167-
# - deploy_alpha:
168-
# requires:
169-
# - test_static_js
170-
# - test_web
171-
# filters:
172-
# branches:
173-
# only: alpha
172+
- build_web:
173+
requires:
174+
- checkout_environment
175+
- test_e2e:
176+
requires:
177+
- build_web

api/models/directMessageThread.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NEW_DOCUMENTS } from './utils';
44
import { createChangefeed } from 'shared/changefeed-utils';
55
import { trackQueue } from 'shared/bull/queues';
66
import { events } from 'shared/analytics';
7+
import { getDirectMessageThreadRecords } from './usersDirectMessageThreads';
78

89
export type DBDirectMessageThread = {
910
createdAt: Date,
@@ -100,21 +101,34 @@ const getUpdatedDirectMessageThreadChangefeed = () =>
100101
includeInitial: false,
101102
})
102103
.filter(NEW_DOCUMENTS.or(THREAD_LAST_ACTIVE_CHANGED))('new_val')
103-
.eqJoin('id', db.table('usersDirectMessageThreads'), { index: 'threadId' })
104-
.without({
105-
right: ['id', 'createdAt', 'threadId', 'lastActive', 'lastSeen'],
106-
})
107-
.zip()
108104
.run();
109105

110-
const listenToUpdatedDirectMessageThreads = (cb: Function): Function => {
106+
const listenToUpdatedDirectMessageThreadRecords = (cb: Function) => {
111107
return createChangefeed(
112108
getUpdatedDirectMessageThreadChangefeed,
113109
cb,
114110
'listenToUpdatedDirectMessageThreads'
115111
);
116112
};
117113

114+
const listenToUpdatedDirectMessageThreads = (cb: Function): Function => {
115+
// NOTE(@mxstbr): Running changefeeds on eqJoin's does not work well, so we
116+
// hack around that by listening to record changes and then "faking" an eqJoin
117+
// by doing another db query!
118+
return listenToUpdatedDirectMessageThreadRecords(directMessageThread => {
119+
getDirectMessageThreadRecords(directMessageThread.id).then(
120+
usersDirectMessageThread => {
121+
usersDirectMessageThread.forEach(userDirectMessageThread => {
122+
cb({
123+
...userDirectMessageThread,
124+
...directMessageThread,
125+
});
126+
});
127+
}
128+
);
129+
});
130+
};
131+
118132
// prettier-ignore
119133
const checkForExistingDMThread = async (participants: Array<string>): Promise<?string> => {
120134
// return a list of all threadIds where both participants are active

api/models/usersDirectMessageThreads.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ const isMemberOfDirectMessageThread = (threadId: string, userId: string) => {
124124
.run();
125125
};
126126

127+
const getDirectMessageThreadRecords = (threadId: string) => {
128+
return db
129+
.table('usersDirectMessageThreads')
130+
.getAll(threadId, { index: 'threadId' })
131+
.run();
132+
};
133+
127134
module.exports = {
128135
createMemberInDirectMessageThread,
129136
removeMemberInDirectMessageThread,
@@ -134,4 +141,5 @@ module.exports = {
134141
getMembersInDirectMessageThread,
135142
getMembersInDirectMessageThreads,
136143
isMemberOfDirectMessageThread,
144+
getDirectMessageThreadRecords,
137145
};

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"draft-js-embed-plugin": "^1.2.0",
3636
"draft-js-focus-plugin": "2.0.0-rc2",
3737
"draft-js-image-plugin": "2.0.0-rc8",
38-
"draft-js-import-markdown": "^1.3.1",
38+
"draft-js-import-markdown": "^1.3.3",
3939
"draft-js-linkify-plugin": "^2.0.0-beta1",
4040
"draft-js-markdown-plugin": "^1.4.4",
4141
"draft-js-plugins-editor": "^2.1.1",

api/yarn.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,21 +3534,21 @@ [email protected]:
35343534
prop-types "^15.5.8"
35353535
union-class-names "^1.0.0"
35363536

3537-
draft-js-import-element@^1.3.0:
3538-
version "1.3.0"
3539-
resolved "https://registry.yarnpkg.com/draft-js-import-element/-/draft-js-import-element-1.3.0.tgz#64ca3b32e770cc0227f563cfb362b19bd5c60e4e"
3540-
integrity sha512-asRZSsMbqzpQ3xlUX9+HMuOn/DR8OyWYVV9wdcnPw7QwVUqb3L4XGj0XbDCbdQte0aX8W1DU4BV0nhC2KcSCEQ==
3537+
draft-js-import-element@^1.3.3:
3538+
version "1.3.3"
3539+
resolved "https://registry.yarnpkg.com/draft-js-import-element/-/draft-js-import-element-1.3.3.tgz#e4b5e87f72bc57adb459d786a3d0d58b498b2fa1"
3540+
integrity sha512-E1hiuWuhM9XmX5QFBzKY0blkuPxz+yuK88R1y/xIfLgJtVyfQOnc8vfkGH6tEPbNtdbIcnKI8aCGfCkqgvt5CA==
35413541
dependencies:
3542-
draft-js-utils "^1.3.0"
3543-
synthetic-dom "^1.2.0"
3542+
draft-js-utils "^1.3.3"
3543+
synthetic-dom "^1.3.3"
35443544

3545-
draft-js-import-markdown@^1.3.1:
3546-
version "1.3.1"
3547-
resolved "https://registry.yarnpkg.com/draft-js-import-markdown/-/draft-js-import-markdown-1.3.1.tgz#7ed4f95c7f16acdd4703a5d608497857ed4a4ffa"
3548-
integrity sha512-TTV+X7X5ixPeNWqpGk6CFLYO+5ORCrUENaJPGDOzps7gyT/SMfuILM8DP2FwWjFt3ys2WmFZMlMGKk/M4l/N/Q==
3545+
draft-js-import-markdown@^1.3.3:
3546+
version "1.3.3"
3547+
resolved "https://registry.yarnpkg.com/draft-js-import-markdown/-/draft-js-import-markdown-1.3.3.tgz#cc5e703dc31888757743e94a4eafd25bf012f9ab"
3548+
integrity sha512-O9wQPAVB4TQLZGPYUQDHD1XGK/H7DZKNrSuwDn7RTadWWFycZV4sP46TZPFD4D240xas/h9QwjbxfAg8ZLQwrw==
35493549
dependencies:
3550-
draft-js-import-element "^1.3.0"
3551-
synthetic-dom "^1.2.0"
3550+
draft-js-import-element "^1.3.3"
3551+
synthetic-dom "^1.3.3"
35523552

35533553
draft-js-linkify-plugin@^2.0.0-beta1:
35543554
version "2.0.1"
@@ -3625,10 +3625,10 @@ draft-js-prism@ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb:
36253625
immutable "*"
36263626
prismjs "^1.5.0"
36273627

3628-
draft-js-utils@^1.3.0:
3629-
version "1.3.0"
3630-
resolved "https://registry.yarnpkg.com/draft-js-utils/-/draft-js-utils-1.3.0.tgz#9102ca34450da3de2097a074c6cc9c92f72a312e"
3631-
integrity sha512-wZaY6HQ/jZTh0wshkPzXNrPu0qcE6PuZwIYJp/q8nFAc3elWma7EBtGLXDPkSwvAXEl596mD6GPfk3jnPDuA+w==
3628+
draft-js-utils@^1.3.3:
3629+
version "1.3.3"
3630+
resolved "https://registry.yarnpkg.com/draft-js-utils/-/draft-js-utils-1.3.3.tgz#2330ab98218c835d58dc08eacdba6708b201eb27"
3631+
integrity sha512-ZIF3KE2+dRD6zEoqQyu9HzeG56NWtktfazRnDZFC9GD4NnHgJE5qI+TqGgmjRjSrKzuSQonl5rsx+D4N5m6yhQ==
36323632

36333633
[email protected], draft-js@^0.10.4, draft-js@^0.10.5, draft-js@~0.10.0:
36343634
version "0.10.5"
@@ -9200,10 +9200,10 @@ symbol-tree@^3.2.1:
92009200
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
92019201
integrity sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=
92029202

9203-
synthetic-dom@^1.2.0:
9204-
version "1.2.0"
9205-
resolved "https://registry.yarnpkg.com/synthetic-dom/-/synthetic-dom-1.2.0.tgz#f3589aafe2b5e299f337bb32973a9be42dd5625e"
9206-
integrity sha1-81iar+K14pnzN7sylzqb5C3VYl4=
9203+
synthetic-dom@^1.3.3:
9204+
version "1.3.3"
9205+
resolved "https://registry.yarnpkg.com/synthetic-dom/-/synthetic-dom-1.3.3.tgz#a01865fef513c76c6936f968f90140eb6959a034"
9206+
integrity sha512-ILjWWiiHIAYphm+F3w0V+A4a79HHF3ELZc6v7H3/kVzCvoxqHWTySN10M7vUOMpZFeRkwz/LmXsW10eFu79bdQ==
92079207

92089208
table@^4.0.2:
92099209
version "4.0.3"

built-email-templates/weeklyDigest.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1+
<html xmlns="http://www.w3.org/1999/xhtml">
2+
23
<!--
34
START_CONFIG
45
{
@@ -13,7 +14,6 @@
1314
}
1415
END_CONFIG
1516
-->
16-
<html xmlns="http://www.w3.org/1999/xhtml">
1717

1818
<head>
1919
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -121,7 +121,7 @@ <h3 style="color:#16171A; font-size:16px; font-weight:500; margin-top:0; text-al
121121
</tr>
122122
{{/data.hasOverflowThreads}}
123123

124-
{{#data.communities}}
124+
{{#if data.communities}}
125125
<tr>
126126
<td style="word-break:break-word">
127127
<div class="section-divider" style="border-bottom:1px solid #DAE4F2; display:block; height:1px; margin:32px 0" height="1"></div>
@@ -133,7 +133,7 @@ <h3 style="color:#16171A; font-size:16px; font-weight:500; margin-top:0; text-al
133133
<h2 class="discover-divider" style="color:#16171A; font-size:20px; font-weight:bold; margin-top:0; text-align:left; margin-bottom:0" align="left">Discover more communities:</h2>
134134
</td>
135135
</tr>
136-
{{/data.communities}}
136+
{{/if}}
137137

138138
{{#each data.communities}}
139139
<tr>

email-template-scripts/sendgrid-sync.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ const processPath = path => {
8686
.slice(configStart, configEnd)
8787
.replace('START_CONFIG', '')
8888
.replace(/(\r\n\t|\n|\r\t)/gm, '');
89-
const config = JSON.parse(configString);
89+
90+
let config;
91+
try {
92+
config = JSON.parse(configString);
93+
} catch (err) {
94+
console.error({ err, configString, file, configStart, configEnd });
95+
return;
96+
}
9097

9198
if (!UPDATE_PROD_TEMPLATES && !config.test) {
9299
console.error('🔅 No test config for this template, skipping');

email-templates/weeklyDigest.html

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1+
<!DOCTYPE html
2+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3+
4+
<html xmlns="http://www.w3.org/1999/xhtml">
25

36
<!--
47
START_CONFIG
@@ -15,8 +18,6 @@
1518
END_CONFIG
1619
-->
1720

18-
<html xmlns="http://www.w3.org/1999/xhtml">
19-
2021
<head>
2122
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2223
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -440,7 +441,8 @@ <h3>{{content.title}}</h3>
440441

441442
<td valign="middle">
442443
<p>
443-
Posted in <a href="https://spectrum.chat/{{community.slug}}">{{community.name}}</a>&nbsp;·&nbsp;<a
444+
Posted in <a
445+
href="https://spectrum.chat/{{community.slug}}">{{community.name}}</a>&nbsp;·&nbsp;<a
444446
href="https://spectrum.chat/{{community.slug}}/{{channel.slug}}">{{channel.name}}</a>
445447
</p>
446448
<p>
@@ -470,7 +472,7 @@ <h3>{{content.title}}</h3>
470472
</tr>
471473
{{/data.hasOverflowThreads}}
472474

473-
{{#data.communities}}
475+
{{#if data.communities}}
474476
<tr>
475477
<td>
476478
<div class="section-divider"></div>
@@ -482,12 +484,13 @@ <h3>{{content.title}}</h3>
482484
<h2 class="discover-divider">Discover more communities:</h2>
483485
</td>
484486
</tr>
485-
{{/data.communities}}
487+
{{/if}}
486488

487489
{{#each data.communities}}
488490
<tr>
489491
<td>
490-
<table width="100%" cellpadding="0" cellspacing="0" class="thread-community-header suggested-community">
492+
<table width="100%" cellpadding="0" cellspacing="0"
493+
class="thread-community-header suggested-community">
491494
<tr width="100%" cellpadding="0" cellspacing="0">
492495
<td valign="middle" width="32">
493496
<a href="https://spectrum.chat/{{slug}}" class="block">
@@ -556,7 +559,8 @@ <h2 class="suggested-community-title">{{name}}</h2>
556559
</li>
557560

558561
<li>
559-
<a href="https://spectrum.chat/spectrum/hugs-n-bugs">Report bugs</a> · <a href="https://spectrum.chat/spectrum/feature-requests">Request
562+
<a href="https://spectrum.chat/spectrum/hugs-n-bugs">Report bugs</a> · <a
563+
href="https://spectrum.chat/spectrum/feature-requests">Request
560564
a feature</a>
561565
</li>
562566
</ul>

src/actions/dashboardFeed.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
// @flow
2+
import qs from 'query-string';
23
import { storeItem } from 'src/helpers/localStorage';
34
import { LAST_ACTIVE_COMMUNITY_KEY } from 'src/views/dashboard/components/communityList';
5+
import { history } from 'src/helpers/history';
46

57
export const changeActiveThread = (threadId: ?string) => {
8+
let search = qs.parse(history.location.search);
9+
search.t = threadId;
10+
history.push({
11+
...history.location,
12+
search: qs.stringify(search),
13+
});
614
return {
715
type: 'SELECT_FEED_THREAD',
816
threadId,

0 commit comments

Comments
 (0)