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

Commit 4c9e902

Browse files
authored
Merge pull request #5074 from withspectrum/3.1.9
3.1.9
2 parents 8a1ec71 + cb38737 commit 4c9e902

File tree

10 files changed

+69
-24
lines changed

10 files changed

+69
-24
lines changed

api/models/community.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export const deleteCommunity = (communityId: string, userId: string): Promise<DB
543543
};
544544

545545
// prettier-ignore
546-
export const setPinnedThreadInCommunity = (communityId: string, value: string, userId: string): Promise<DBCommunity> => {
546+
export const setPinnedThreadInCommunity = (communityId: string, value: ?string, userId: string): Promise<DBCommunity> => {
547547
return db
548548
.table('communities')
549549
.get(communityId)

api/mutations/thread/moveThread.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import type { GraphQLContext } from '../../';
33
import UserError from '../../utils/UserError';
44
import { getThread, moveThread } from '../../models/thread';
55
import { getUserPermissionsInCommunity } from '../../models/usersCommunities';
6-
import { getChannels } from '../../models/channel';
6+
import { getChannelById } from '../../models/channel';
7+
import {
8+
getCommunityById,
9+
setPinnedThreadInCommunity,
10+
} from '../../models/community';
711
import { isAuthedResolver as requireAuth } from '../../utils/permissions';
812
import { events } from 'shared/analytics';
913
import { trackQueue } from 'shared/bull/queues';
@@ -18,6 +22,7 @@ export default requireAuth(async (_: any, args: Input, ctx: GraphQLContext) => {
1822
const { threadId, channelId } = args;
1923

2024
const thread = await getThread(threadId);
25+
2126
if (!thread) {
2227
trackQueue.add({
2328
userId: user.id,
@@ -65,7 +70,11 @@ export default requireAuth(async (_: any, args: Input, ctx: GraphQLContext) => {
6570
);
6671
}
6772

68-
const [newChannel] = await getChannels([channelId]);
73+
const [newChannel, community] = await Promise.all([
74+
getChannelById(channelId),
75+
getCommunityById(thread.communityId),
76+
]);
77+
6978
if (newChannel.communityId !== thread.communityId) {
7079
trackQueue.add({
7180
userId: user.id,
@@ -81,6 +90,16 @@ export default requireAuth(async (_: any, args: Input, ctx: GraphQLContext) => {
8190
);
8291
}
8392

93+
// if the thread is being moved into a private channel, make sure it is not pinned
94+
// in the community
95+
if (
96+
newChannel.isPrivate &&
97+
community.pinnedThreadId &&
98+
thread.id === community.pinnedThreadId
99+
) {
100+
await setPinnedThreadInCommunity(thread.communityId, null, user.id);
101+
}
102+
84103
return moveThread(threadId, channelId, user.id).then(res => {
85104
if (res) return res;
86105

api/yarn.lock

+9-9
Original file line numberDiff line numberDiff line change
@@ -3309,11 +3309,6 @@ decorate-component-with-props@^1.0.2:
33093309
resolved "https://registry.yarnpkg.com/decorate-component-with-props/-/decorate-component-with-props-1.1.0.tgz#b496c814c6a2aba0cf2ad26e44cbedb8ead42f15"
33103310
integrity sha512-tTYQojixN64yK3/WBODMfvss/zbmyUx9HQXhzSxZiSiofeekVeRyyuToy9BCiTMrVEIKWxTcla2t3y5qdaUF7Q==
33113311

3312-
deep-equal@^1.0.1:
3313-
version "1.0.1"
3314-
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
3315-
integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=
3316-
33173312
deep-extend@^0.4.0:
33183313
version "0.4.2"
33193314
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
@@ -8021,14 +8016,19 @@ react-dom@^15.4.1:
80218016
object-assign "^4.1.0"
80228017
prop-types "^15.5.10"
80238018

8019+
react-fast-compare@^2.0.2:
8020+
version "2.0.4"
8021+
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"
8022+
integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==
8023+
80248024
8025-
version "5.2.0"
8026-
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.0.tgz#a81811df21313a6d55c5f058c4aeba5d6f3d97a7"
8027-
integrity sha1-qBgR3yExOm1VxfBYxK66XW89l6c=
8025+
version "5.2.1"
8026+
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.1.tgz#16a7192fdd09951f8e0fe22ffccbf9bb3e591ffa"
8027+
integrity sha512-CnwD822LU8NDBnjCpZ4ySh8L6HYyngViTZLfBBb3NjtrpN8m49clH8hidHouq20I51Y6TpCTISCBbqiY5GamwA==
80288028
dependencies:
8029-
deep-equal "^1.0.1"
80308029
object-assign "^4.1.1"
80318030
prop-types "^15.5.4"
8031+
react-fast-compare "^2.0.2"
80328032
react-side-effect "^1.1.0"
80338033

80348034
react-infinite-scroller-with-scroll-element@^1.0.4:

package.json

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

src/components/composer/style.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import styled, { css } from 'styled-components';
33
import theme from 'shared/theme';
44
import Icon from 'src/components/icon';
55
import { hexa, FlexRow, FlexCol, zIndex } from '../globals';
6-
import { MAX_WIDTH, MEDIA_BREAK, TITLEBAR_HEIGHT } from 'src/components/layout';
6+
import {
7+
COL_GAP,
8+
MAX_WIDTH,
9+
MEDIA_BREAK,
10+
TITLEBAR_HEIGHT,
11+
NAVBAR_EXPANDED_WIDTH,
12+
NAVBAR_WIDTH,
13+
MIN_WIDTH_TO_EXPAND_NAVIGATION,
14+
} from 'src/components/layout';
715

816
export const DropzoneWrapper = styled.div`
917
position: sticky;
@@ -30,13 +38,26 @@ export const DropImageOverlay = (props: {
3038
};
3139

3240
export const Wrapper = styled.div`
33-
grid-area: main;
3441
display: flex;
3542
justify-content: center;
3643
z-index: 9995;
44+
position: fixed;
45+
max-width: ${MAX_WIDTH}px;
46+
left: ${NAVBAR_WIDTH + COL_GAP}px;
47+
width: 100%;
48+
max-width: calc(100% - ${NAVBAR_WIDTH * 2}px);
3749
3850
@media (max-width: ${MEDIA_BREAK}px) {
3951
height: calc(100vh - ${TITLEBAR_HEIGHT}px);
52+
left: 0;
53+
right: 0;
54+
bottom: 0;
55+
max-width: 100%;
56+
}
57+
58+
@media (min-width: ${MIN_WIDTH_TO_EXPAND_NAVIGATION}px) {
59+
left: ${NAVBAR_EXPANDED_WIDTH + COL_GAP}px;
60+
max-width: calc(100% - ${NAVBAR_EXPANDED_WIDTH * 2}px);
4061
}
4162
`;
4263

src/components/entities/listItems/channel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const Channel = (props: Props) => {
145145

146146
return (
147147
<ErrorBoundary>
148-
<Link to={`/${channel.community.slug}/${channel.slug}`}>
148+
<Link to={`/${channel.community.slug}/${channel.slug}?tab=posts`}>
149149
<Row isActive={isActive}>
150150
<Content>
151151
{name && (

src/components/message/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ class Message extends React.Component<Props, State> {
191191
const searchObj = queryString.parse(location.search);
192192
const { m = null } = searchObj;
193193
const isSelected = m && m === selectedMessageId;
194-
194+
const isOptimistic =
195+
message && typeof message.id === 'number' && message.id < 0;
195196
return (
196197
<ConditionalWrap
197198
condition={!!isSelected}
@@ -298,7 +299,7 @@ class Message extends React.Component<Props, State> {
298299
/>
299300
)}
300301

301-
{!isEditing && (
302+
{!isEditing && !isOptimistic && (
302303
<ActionsContainer>
303304
<Actions>
304305
{canEditMessage && (

src/components/message/threadAttachment/attachment.js

+6-3
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 type { Props } from './';
45
import compose from 'recompose/compose';
56
import { Loading } from 'src/components/loading';
@@ -12,7 +13,7 @@ import getThreadLink from 'src/helpers/get-thread-link';
1213

1314
class Attachment extends React.Component<Props> {
1415
render() {
15-
const { data, currentUser } = this.props;
16+
const { data, currentUser, id } = this.props;
1617
const { thread, loading, error } = data;
1718

1819
if (loading)
@@ -23,9 +24,11 @@ class Attachment extends React.Component<Props> {
2324
</Container>
2425
</div>
2526
);
26-
if (error) return null;
2727

28-
if (!thread) return null;
28+
if (error || !thread)
29+
return (
30+
<Link to={`/thread/${id}`}>https://spectrum.chat/thread/{id}</Link>
31+
);
2932

3033
return (
3134
<div className="attachment-container">

src/components/message/threadAttachment/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ import Attachment from './attachment';
1212
export type Props = {
1313
currentUser: UserInfoType,
1414
message: MessageInfoType,
15+
id: string,
1516
data: {
1617
thread: GetThreadType,
1718
loading: boolean,
1819
error: ?string,
1920
},
2021
};
2122

22-
const Query = ({ data, message, ...rest }: Props) => (
23-
<Attachment message={message} data={data} />
23+
const Query = ({ data, message, id, ...rest }: Props) => (
24+
<Attachment message={message} id={id} data={data} />
2425
);
2526

2627
const ThreadAttachment = compose(getThreadById)(Query);

src/views/thread/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export const StickyHeaderContent = styled.div`
475475
display: flex;
476476
padding: 12px 16px;
477477
cursor: pointer;
478-
max-width: 70%;
478+
max-width: 560px;
479479
480480
@media (max-width: 728px) {
481481
padding: 16px;

0 commit comments

Comments
 (0)