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

Commit 11c460a

Browse files
authored
Merge pull request #3323 from withspectrum/2.4.9
2.4.9
2 parents 6da5ae0 + f51ba5c commit 11c460a

File tree

35 files changed

+196
-198
lines changed

35 files changed

+196
-198
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ YES
2121

2222
**Release notes for users (delete if codebase-only change)**
2323
-
24-
<!--
25-
If your pull request introduces changes to the user interface on Spectrum, please share before and after screenshots of the changes (gifs or videos are encouraged for interaction changes). Please include screenshots of desktop and mobile viewports to ensure that all responsive cases are reviewed.
26-
-->
2724

28-
**Related issues (delete if you don't know any existing issue(s) that could be related to this PR)**
29-
<!--
30-
If your PR closes an existing issue you can write "Closes #issue_number" or if it's related to another issue you can write "Related to #issue_number"
31-
-->
25+
**Related issues (delete if you don't know of any)**
26+
Closes #
27+
28+
<!-- If there are UI changes please share mobile and desktop screenshots or recordings. -->
29+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Spectrum has been under full-time development since March, 2017. See [the roadma
4141
- [Roadmap](https://github.com/withspectrum/spectrum/projects/19)
4242
- [Technical](docs/)
4343
- [Testing](docs/testing/intro.md)
44-
- [Background Jobs](docs/backend/background-jobs.md)
44+
- [Background Jobs](docs/workers/background-jobs.md)
4545
- [Deployment](docs/deployments.md)
4646
- [API](docs/backend/api/)
4747
- [Fragments](docs/backend/api/fragments.md)

api/models/channel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const channelsByCommunitiesQuery = (...communityIds: string[]) =>
1010
db
1111
.table('channels')
1212
.getAll(...communityIds, { index: 'communityId' })
13-
.filter(channel => db.not(channel.hasFields('deletedAt')));
13+
.filter(channel => channel.hasFields('deletedAt').not());
1414

1515
const channelsByIdsQuery = (...channelIds: string[]) =>
1616
db
1717
.table('channels')
1818
.getAll(...channelIds)
19-
.filter(channel => db.not(channel.hasFields('deletedAt')));
19+
.filter(channel => channel.hasFields('deletedAt').not());
2020

2121
const threadsByChannelsQuery = (...channelIds: string[]) =>
2222
channelsByIdsQuery(...channelIds)

api/models/search.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export const getUsersJoinedChannels = (userId: string): Promise<Array<string>> =
9191
.table('usersChannels')
9292
.getAll(userId, { index: 'userId' })
9393
.filter({ isMember: true })
94+
.eqJoin('channelId', db.table('channels'))
95+
.filter(row => row('right').hasFields('deletedAt').not())
96+
.zip()
9497
.map(row => row('channelId'))
9598
.run();
9699
};
@@ -101,6 +104,9 @@ export const getUsersJoinedCommunities = (userId: string): Promise<Array<string>
101104
.table('usersCommunities')
102105
.getAll(userId, { index: 'userId' })
103106
.filter({ isMember: true })
107+
.eqJoin('communityId', db.table('communities'))
108+
.filter(row => row('right').hasFields('deletedAt').not())
109+
.zip()
104110
.map(row => row('communityId'))
105111
.run();
106112
};
@@ -112,7 +118,7 @@ export const getUsersJoinedPrivateChannelIds = (userId: string): Promise<Array<s
112118
.getAll(userId, { index: 'userId' })
113119
.filter({ isMember: true })
114120
.eqJoin('channelId', db.table('channels'))
115-
.filter(row => row('right')('isPrivate').eq(true))
121+
.filter(row => row('right')('isPrivate').eq(true).and(row('right').hasFields('deletedAt').not()))
116122
.without({ left: ['id'] })
117123
.zip()
118124
.map(row => row('id'))
@@ -126,7 +132,7 @@ export const getUsersJoinedPrivateCommunityIds = (userId: string): Promise<Array
126132
.getAll(userId, { index: 'userId' })
127133
.filter({ isMember: true })
128134
.eqJoin('communityId', db.table('communities'))
129-
.filter(row => row('right')('isPrivate').eq(true))
135+
.filter(row => row('right')('isPrivate').eq(true).and(row('right').hasFields('deletedAt').not()))
130136
.without({ left: ['id'] })
131137
.zip()
132138
.map(row => row('id'))

api/queries/search/searchThreads.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
109109
);
110110

111111
return loaders.thread
112-
.loadMany(searchResultThreads.map(t => t.threadId))
112+
.loadMany(searchResultThreads.map(t => t && t.threadId))
113113
.then(data => data.filter(thread => thread && !thread.deletedAt));
114114
}
115115

@@ -168,7 +168,7 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
168168
.filter(t => t.communityId === searchFilter.communityId);
169169

170170
return loaders.thread
171-
.loadMany(searchResultThreads.map(t => t.threadId))
171+
.loadMany(searchResultThreads.map(t => t && t.threadId))
172172
.then(data => data.filter(thread => thread && !thread.deletedAt));
173173
}
174174

@@ -239,7 +239,7 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
239239
.filter(t => t.creatorId === searchFilter.creatorId);
240240

241241
return loaders.thread
242-
.loadMany(searchResultThreads.map(t => t.threadId))
242+
.loadMany(searchResultThreads.map(t => t && t.threadId))
243243
.then(data => data.filter(thread => thread && !thread.deletedAt));
244244
}
245245

@@ -269,7 +269,7 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
269269
.filter(t => availableCommunitiesForSearch.indexOf(t.communityId) >= 0);
270270

271271
return loaders.thread
272-
.loadMany(searchResultThreads.map(t => t.threadId))
272+
.loadMany(searchResultThreads.map(t => t && t.threadId))
273273
.then(data => data.filter(thread => thread && !thread.deletedAt));
274274
}
275275

@@ -282,11 +282,11 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
282282

283283
// first, lets get the channels where the thread results were posted
284284
const channelsOfThreads = await getChannels(
285-
searchResultThreads.map(t => t.channelId)
285+
searchResultThreads.map(t => t && t.channelId)
286286
);
287287

288288
const communitiesOfThreads = await getCommunities(
289-
searchResultThreads.map(t => t.communityId)
289+
searchResultThreads.map(t => t && t.communityId)
290290
);
291291

292292
// see if any channels where thread results were found are private
@@ -305,7 +305,7 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
305305
(!privateCommunityIds || privateCommunityIds.length === 0)
306306
) {
307307
return loaders.thread
308-
.loadMany(searchResultThreads.map(t => t.threadId))
308+
.loadMany(searchResultThreads.map(t => t && t.threadId))
309309
.then(data => data.filter(thread => thread && !thread.deletedAt));
310310
} else {
311311
// otherwise here we know that the user found threads where some of them are
@@ -332,6 +332,8 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
332332
// for each thread in the search results, determine if it was posted in
333333
// a private channel. if yes, is the current user a member?
334334
searchResultThreads = searchResultThreads.filter(thread => {
335+
if (!thread) return null;
336+
335337
if (privateChannelIds.indexOf(thread.channelId) >= 0) {
336338
return availablePrivateChannels.indexOf(thread.channelId) >= 0;
337339
}
@@ -344,7 +346,7 @@ export default async (args: Args, { loaders, user }: GraphQLContext) => {
344346
});
345347

346348
return loaders.thread
347-
.loadMany(searchResultThreads.map(t => t.threadId))
349+
.loadMany(searchResultThreads.map(t => t && t.threadId))
348350
.then(data => data.filter(thread => thread && !thread.deletedAt));
349351
}
350352
};

api/queries/thread/rootThread.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default async (
2121
]);
2222

2323
// if the channel is private, don't return any thread data
24-
if (channel.isPrivate || community.isPrivate) return null;
24+
if (!channel || !community || channel.isPrivate || community.isPrivate)
25+
return null;
2526
return thread;
2627
} else {
2728
// if the user is signed in, we need to check if the channel is private as well as the user's permission in that channel
@@ -38,6 +39,7 @@ export default async (
3839
]);
3940

4041
// if the thread is in a private channel where the user is not a member, don't return any thread data
42+
if (!channel || !community) return null;
4143
if (
4244
channel.isPrivate &&
4345
(!channelPermissions || !channelPermissions.isMember)

cypress/integration/thread/action_bar_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('action bar renders', () => {
139139
cy.get('[data-cy="thread-notifications-toggle"]').should('be.visible');
140140
cy.get('[data-cy="thread-facebook-button"]').should('not.be.visible');
141141
cy.get('[data-cy="thread-tweet-button"]').should('not.be.visible');
142-
cy.get('[data-cy="thread-copy-link-button"]').should('not.be.visible');
142+
cy.get('[data-cy="thread-copy-link-button"]').should('be.visible');
143143
cy
144144
.get('[data-cy="thread-actions-dropdown-trigger"]')
145145
.should('not.be.visible');

mobile/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dependencies": {
55
"@expo/react-native-action-sheet": "^1.0.2",
66
"apollo-cache-inmemory": "^1.1.12",
7-
"apollo-client": "^2.2.8",
7+
"apollo-client": "^2.3.2",
88
"apollo-link": "^1.2.2",
99
"apollo-link-error": "^1.0.9",
1010
"apollo-link-http": "^1.5.4",

mobile/views/Channel/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class Channel extends Component<Props> {
5757
} else {
5858
title = 'Loading channel...';
5959
}
60-
if (navigation.state.params.title === title) return;
60+
const oldTitle = navigation.getParam('title', null);
61+
if (oldTitle && oldTitle === title) return;
6162
navigation.setParams({ title });
6263
};
6364

mobile/views/Community/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class Community extends Component<Props> {
7878
} else {
7979
title = 'Loading community...';
8080
}
81-
if (navigation.state.params.title === title) return;
81+
const oldTitle = navigation.getParam('title', null);
82+
if (oldTitle && oldTitle === title) return;
8283
navigation.setParams({ title });
8384
};
8485

0 commit comments

Comments
 (0)