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

Commit

Permalink
Merge pull request #5069 from withspectrum/3.1.8
Browse files Browse the repository at this point in the history
3.1.8
  • Loading branch information
brianlovin authored May 1, 2019
2 parents c07d41a + d7f06cd commit 8a1ec71
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
7 changes: 5 additions & 2 deletions api/models/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const getChannelsByCommunity = (communityId: string): Promise<Array<DBChannel>>
const getPublicChannelsByCommunity = (communityId: string): Promise<Array<string>> => {
return channelsByCommunitiesQuery(communityId)
.filter({ isPrivate: false })
.filter(row => row.hasFields('archivedAt').not())
.map(c => c('id'))
.run();
};
Expand All @@ -59,8 +60,10 @@ const getPublicChannelsByCommunity = (communityId: string): Promise<Array<string
*/
// prettier-ignore
const getChannelsByUserAndCommunity = async (communityId: string, userId: string): Promise<Array<string>> => {
const channelIds = await channelsByCommunitiesQuery(communityId)('id').run();

const channels = await channelsByCommunitiesQuery(communityId).run();
const unarchived = channels.filter(channel => !channel.archivedAt)
const channelIds = unarchived.map(channel => channel.id)

return db
.table('usersChannels')
.getAll(...channelIds.map(id => ([userId, id])), {
Expand Down
2 changes: 0 additions & 2 deletions api/models/test/__snapshots__/channel.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ exports[`models/channel getChannelsByUserAndCommunity returns correct set of cha
Array [
"2",
"1",
"5",
]
`;

Expand Down Expand Up @@ -227,7 +226,6 @@ Array [

exports[`models/channel getPublicChannelsByCommunity returns correct set of channels 1`] = `
Array [
"5",
"1",
"8",
]
Expand Down
7 changes: 0 additions & 7 deletions api/test/__snapshots__/community.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ Object {
},
},
},
Object {
"node": Object {
"content": Object {
"title": "Yet another thread",
},
},
},
Object {
"node": Object {
"content": Object {
Expand Down
3 changes: 3 additions & 0 deletions cypress/integration/community/view/profile_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('public community signed out', () => {
.filter(channel => channel.communityId === publicCommunity.id)
.filter(channel => !channel.isPrivate)
.filter(channel => !channel.deletedAt)
.filter(channel => !channel.archivedAt)
.forEach(channel => {
cy.contains(channel.name)
.scrollIntoView()
Expand Down Expand Up @@ -140,6 +141,7 @@ describe('public community signed in without permission', () => {
.filter(channel => channel.communityId === publicCommunity.id)
.filter(channel => !channel.isPrivate)
.filter(channel => !channel.deletedAt)
.filter(channel => !channel.archivedAt)
.forEach(channel => {
cy.contains(channel.name)
.scrollIntoView()
Expand Down Expand Up @@ -271,6 +273,7 @@ describe('private community signed in with permissions', () => {
.filter(channel => channel.communityId === privateCommunity.id)
.filter(channel => !channel.isPrivate)
.filter(channel => !channel.deletedAt)
.filter(channel => !channel.archivedAt)
.forEach(channel => {
cy.get('[data-cy="channel-list"]')
.contains(channel.name)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Spectrum",
"version": "3.1.7",
"version": "3.1.8",
"license": "BSD-3-Clause",
"devDependencies": {
"@babel/preset-flow": "^7.0.0",
Expand Down
13 changes: 10 additions & 3 deletions src/views/community/components/channelsList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import * as React from 'react';
import { connect } from 'react-redux';
import { Route, Link } from 'react-router-dom';
import { Route, Link, withRouter, type Location } from 'react-router-dom';
import compose from 'recompose/compose';
import type { Dispatch } from 'redux';
import { Query, Mutation } from 'react-apollo';
Expand Down Expand Up @@ -39,9 +39,10 @@ type Props = {
dispatch: Dispatch<Object>,
currentUser: Object,
communitySlug: string,
location: Location,
};

const ChatTab = ({ community, currentUser }) =>
const ChatTab = ({ location, community, currentUser }) =>
!community.watercoolerId ? null : (
<Route exact path={`/${community.slug}`}>
{({ match }) => {
Expand Down Expand Up @@ -161,6 +162,7 @@ class Component extends React.Component<Props> {
isLoading,
currentUser,
data: { community },
location,
} = this.props;

if (isLoading) {
Expand Down Expand Up @@ -206,7 +208,11 @@ class Component extends React.Component<Props> {
</SidebarSectionHeader>

<List data-cy="channel-list">
<ChatTab community={community} currentUser={currentUser} />
<ChatTab
location={location}
community={community}
currentUser={currentUser}
/>
<Route exact path={`/${community.slug}`}>
{({ match }) => (
<Link to={`/${community.slug}?tab=posts`}>
Expand Down Expand Up @@ -260,5 +266,6 @@ export const ChannelsList = compose(
getCommunityChannels,
viewNetworkHandler,
withCurrentUser,
withRouter,
connect()
)(Component);

0 comments on commit 8a1ec71

Please sign in to comment.