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

Commit dc2287f

Browse files
authored
Merge pull request #4796 from withspectrum/fix-thread-links
Fix thread links across the board
2 parents 047dbc0 + 51fedbf commit dc2287f

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

src/components/composer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ class ComposerWithData extends React.Component<Props, State> {
396396
this.props.history.replace(`/?t=${id}`);
397397
this.props.dispatch(changeActiveThread(id));
398398
} else if (this.props.location.pathname === '/new/thread') {
399-
this.props.history.replace(`/${getThreadLink(data.publishThread)}`);
399+
this.props.history.replace(getThreadLink(data.publishThread));
400400
} else {
401-
this.props.history.push(`/${getThreadLink(data.publishThread)}`);
401+
this.props.history.push(getThreadLink(data.publishThread));
402402
this.props.dispatch(changeActiveThread(null));
403403
}
404404
return;

src/components/message/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class Message extends React.Component<Props, State> {
178178
const selectedMessageId = btoa(new Date(message.timestamp).getTime() - 1);
179179
const messageUrl =
180180
threadType === 'story' && thread
181-
? `/${getThreadLink(thread)}?m=${selectedMessageId}`
181+
? `${getThreadLink(thread)}?m=${selectedMessageId}`
182182
: threadType === 'directMessageThread'
183183
? `/messages/${threadId}?m=${selectedMessageId}`
184184
: `/thread/${threadId}?m=${selectedMessageId}`;
@@ -382,7 +382,7 @@ class Message extends React.Component<Props, State> {
382382
}}
383383
data-clipboard-text={
384384
thread
385-
? `${CLIENT_URL}/${getThreadLink(
385+
? `${CLIENT_URL}${getThreadLink(
386386
thread
387387
)}?m=${selectedMessageId}`
388388
: `${CLIENT_URL}/thread/${threadId}?m=${selectedMessageId}`

src/helpers/get-thread-link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ThreadInfoType } from 'shared/graphql/fragments/thread/threadInfo'
44

55
const getThreadLink = (thread: ThreadInfoType) => {
66
if (!thread.community || !thread.channel) return `/thread/${thread.id}`;
7-
return `${thread.community.slug}/${thread.channel.slug}/${slugg(
7+
return `/${thread.community.slug}/${thread.channel.slug}/${slugg(
88
thread.content.title
99
)}~${thread.id}`;
1010
};

src/views/thread/components/actionBar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class ActionBar extends React.Component<Props, State> {
289289
<a
290290
href={`https://www.facebook.com/sharer/sharer.php?t=${encodeURIComponent(
291291
thread.content.title
292-
)}&u=https://spectrum.chat/${getThreadLink(thread)}`}
292+
)}&u=https://spectrum.chat${getThreadLink(thread)}`}
293293
target="_blank"
294294
rel="noopener noreferrer"
295295
>
@@ -310,7 +310,7 @@ class ActionBar extends React.Component<Props, State> {
310310
data-cy="thread-tweet-button"
311311
>
312312
<a
313-
href={`https://twitter.com/share?url=https://spectrum.chat/${getThreadLink(
313+
href={`https://twitter.com/share?url=https://spectrum.chat${getThreadLink(
314314
thread
315315
)}&text=${encodeURIComponent(
316316
thread.content.title
@@ -330,7 +330,7 @@ class ActionBar extends React.Component<Props, State> {
330330

331331
<Clipboard
332332
style={{ background: 'none' }}
333-
data-clipboard-text={`${CLIENT_URL}/${getThreadLink(thread)}`}
333+
data-clipboard-text={`${CLIENT_URL}${getThreadLink(thread)}`}
334334
onSuccess={() =>
335335
this.props.dispatch(
336336
addToastWithTimeout('success', 'Copied to clipboard')
@@ -359,7 +359,7 @@ class ActionBar extends React.Component<Props, State> {
359359
<ShareButtons>
360360
<Clipboard
361361
style={{ background: 'none' }}
362-
data-clipboard-text={`https://spectrum.chat/${getThreadLink(
362+
data-clipboard-text={`https://spectrum.chat${getThreadLink(
363363
thread
364364
)}`}
365365
onSuccess={() =>

src/views/thread/components/messages.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class MessagesWithData extends React.Component<Props, State> {
205205
<A
206206
href={`https://twitter.com/share?text=${encodeURIComponent(
207207
threadTitle
208-
)} on @withspectrum&url=https://spectrum.chat/${getThreadLink(
208+
)} on @withspectrum&url=https://spectrum.chat${getThreadLink(
209209
this.props.data.thread
210210
)}`}
211211
target="_blank"
@@ -216,7 +216,7 @@ class MessagesWithData extends React.Component<Props, State> {
216216
</Button>
217217
</A>
218218
<A
219-
href={`https://www.facebook.com/sharer/sharer.php?u=https://spectrum.chat/${getThreadLink(
219+
href={`https://www.facebook.com/sharer/sharer.php?u=https://spectrum.chat${getThreadLink(
220220
this.props.data.thread
221221
)}&t=${encodeURIComponent(threadTitle)}`}
222222
target="_blank"
@@ -301,7 +301,7 @@ class MessagesWithData extends React.Component<Props, State> {
301301
)}
302302
<link
303303
rel="canonical"
304-
href={'https://spectrum.chat/' + getThreadLink(thread)}
304+
href={'https://spectrum.chat' + getThreadLink(thread)}
305305
/>
306306
</Head>
307307
</div>
@@ -316,7 +316,7 @@ class MessagesWithData extends React.Component<Props, State> {
316316
)}
317317
<link
318318
rel="canonical"
319-
href={'https://spectrum.chat/' + getThreadLink(thread)}
319+
href={'https://spectrum.chat' + getThreadLink(thread)}
320320
/>
321321
</Head>
322322
)}

src/views/thread/components/sidebar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ class Sidebar extends React.Component<Props> {
8484
const loginUrl =
8585
thread && thread.community
8686
? thread.community.brandedLogin.isEnabled
87-
? `/${thread.community.slug}/login?r=${CLIENT_URL}/${getThreadLink(
87+
? `/${thread.community.slug}/login?r=${CLIENT_URL}${getThreadLink(
8888
thread
8989
)}`
90-
: `/login?r=${CLIENT_URL}/${getThreadLink(thread)}`
90+
: `/login?r=${CLIENT_URL}${getThreadLink(thread)}`
9191
: '/login';
9292

9393
return (

src/views/thread/components/threadCommunityBanner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ class ThreadCommunityBanner extends React.Component<Props, State> {
112112
const { isLoading } = this.state;
113113

114114
const loginUrl = community.brandedLogin.isEnabled
115-
? `/${community.slug}/login?r=${CLIENT_URL}/${getThreadLink(thread)}`
116-
: `/login?r=${CLIENT_URL}/${getThreadLink(thread)}`;
115+
? `/${community.slug}/login?r=${CLIENT_URL}${getThreadLink(thread)}`
116+
: `/login?r=${CLIENT_URL}${getThreadLink(thread)}`;
117117

118118
const createdAt = new Date(thread.createdAt).getTime();
119119
const timestamp = convertTimestampToDate(createdAt);
@@ -139,7 +139,7 @@ class ThreadCommunityBanner extends React.Component<Props, State> {
139139
{channel.name}
140140
</Link>
141141
</ChannelHoverProfile>
142-
<Link to={'/' + getThreadLink(thread)}>
142+
<Link to={getThreadLink(thread)}>
143143
&nbsp;
144144
{${timestamp}`}
145145
</Link>

src/views/thread/components/threadDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class ThreadDetailPure extends React.Component<Props, State> {
386386
</Link>
387387
</ChannelHoverProfile>
388388
<span>&nbsp;·&nbsp;</span>
389-
<Link to={'/' + getThreadLink(thread)}>
389+
<Link to={getThreadLink(thread)}>
390390
{timestamp}
391391
{thread.modifiedAt && (
392392
<React.Fragment>

src/views/thread/components/watercoolerActionBar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class WatercoolerActionBar extends React.Component<Props, State> {
8585
<a
8686
href={`https://www.facebook.com/sharer/sharer.php?t=${encodeURIComponent(
8787
thread.content.title
88-
)}&u=https://spectrum.chat/${getThreadLink(thread)}`}
88+
)}&u=https://spectrum.chat${getThreadLink(thread)}`}
8989
target="_blank"
9090
rel="noopener noreferrer"
9191
>
@@ -102,7 +102,7 @@ class WatercoolerActionBar extends React.Component<Props, State> {
102102
<a
103103
href={`https://twitter.com/share?text=${encodeURIComponent(
104104
thread.content.title
105-
)} on @withspectrum&url=https://spectrum.chat/${getThreadLink(
105+
)} on @withspectrum&url=https://spectrum.chat${getThreadLink(
106106
thread
107107
)}`}
108108
target="_blank"
@@ -114,7 +114,7 @@ class WatercoolerActionBar extends React.Component<Props, State> {
114114

115115
<Clipboard
116116
style={{ background: 'none' }}
117-
data-clipboard-text={`https://spectrum.chat/${getThreadLink(
117+
data-clipboard-text={`https://spectrum.chat${getThreadLink(
118118
thread
119119
)}`}
120120
onSuccess={() =>

src/views/thread/container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ class ThreadContainer extends React.Component<Props, State> {
508508
>
509509
<link
510510
rel="canonical"
511-
href={`https://spectrum.chat/${getThreadLink(thread)}`}
511+
href={`https://spectrum.chat${getThreadLink(thread)}`}
512512
/>
513513
{metaImage && (
514514
<meta name="twitter:card" content="summary_large_image" />

0 commit comments

Comments
 (0)