Skip to content

Commit 6960cc5

Browse files
committed
Revert "Include preview cards in status entity in REST API (mastodon#9120)"
1 parent 8995fd8 commit 6960cc5

9 files changed

Lines changed: 17 additions & 55 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ def cache_collection(raw, klass)
126126
def respond_with_error(code)
127127
respond_to do |format|
128128
format.any { head code }
129-
130129
format.html do
131130
set_locale
132131
render "errors/#{code}", layout: 'error', status: code

app/javascript/mastodon/components/status.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import DisplayName from './display_name';
99
import StatusContent from './status_content';
1010
import StatusActionBar from './status_action_bar';
1111
import AttachmentList from './attachment_list';
12-
import Card from '../features/status/components/card';
1312
import { injectIntl, FormattedMessage } from 'react-intl';
1413
import ImmutablePureComponent from 'react-immutable-pure-component';
1514
import { MediaGallery, Video } from '../features/ui/util/async-components';
@@ -258,14 +257,6 @@ class Status extends ImmutablePureComponent {
258257
</Bundle>
259258
);
260259
}
261-
} else if (status.get('spoiler_text').length === 0 && status.get('card')) {
262-
media = (
263-
<Card
264-
onOpenMedia={this.props.onOpenMedia}
265-
card={status.get('card')}
266-
compact
267-
/>
268-
);
269260
}
270261

271262
if (otherAccounts) {

app/javascript/mastodon/features/status/components/card.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default class Card extends React.PureComponent {
6464

6565
static defaultProps = {
6666
maxDescription: 50,
67-
compact: false,
6867
};
6968

7069
state = {
@@ -133,25 +132,25 @@ export default class Card extends React.PureComponent {
133132
}
134133

135134
render () {
136-
const { card, maxDescription, compact } = this.props;
137-
const { width, embedded } = this.state;
135+
const { card, maxDescription } = this.props;
136+
const { width, embedded } = this.state;
138137

139138
if (card === null) {
140139
return null;
141140
}
142141

143142
const provider = card.get('provider_name').length === 0 ? decodeIDNA(getHostname(card.get('url'))) : card.get('provider_name');
144-
const horizontal = (!compact && card.get('width') > card.get('height') && (card.get('width') + 100 >= width)) || card.get('type') !== 'link' || embedded;
143+
const horizontal = card.get('width') > card.get('height') && (card.get('width') + 100 >= width) || card.get('type') !== 'link';
144+
const className = classnames('status-card', { horizontal });
145145
const interactive = card.get('type') !== 'link';
146-
const className = classnames('status-card', { horizontal, compact, interactive });
147146
const title = interactive ? <a className='status-card__title' href={card.get('url')} title={card.get('title')} rel='noopener' target='_blank'><strong>{card.get('title')}</strong></a> : <strong className='status-card__title' title={card.get('title')}>{card.get('title')}</strong>;
148147
const ratio = card.get('width') / card.get('height');
149148
const height = (compact && !embedded) ? (width / (16 / 9)) : (width / ratio);
150149

151150
const description = (
152151
<div className='status-card__content'>
153152
{title}
154-
{!(horizontal || compact) && <p className='status-card__description'>{trim(card.get('description') || '', maxDescription)}</p>}
153+
{!horizontal && <p className='status-card__description'>{trim(card.get('description') || '', maxDescription)}</p>}
155154
<span className='status-card__host'>{provider}</span>
156155
</div>
157156
);
@@ -176,7 +175,7 @@ export default class Card extends React.PureComponent {
176175
<div className='status-card__actions'>
177176
<div>
178177
<button onClick={this.handleEmbedClick}><i className={`fa fa-${iconVariant}`} /></button>
179-
{horizontal && <a href={card.get('url')} target='_blank' rel='noopener'><i className='fa fa-external-link' /></a>}
178+
<a href={card.get('url')} target='_blank' rel='noopener'><i className='fa fa-external-link' /></a>
180179
</div>
181180
</div>
182181
</div>
@@ -186,7 +185,7 @@ export default class Card extends React.PureComponent {
186185
return (
187186
<div className={className} ref={this.setRef}>
188187
{embed}
189-
{!compact && description}
188+
{description}
190189
</div>
191190
);
192191
} else if (card.get('image')) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { connect } from 'react-redux';
2+
import Card from '../components/card';
3+
4+
const mapStateToProps = (state, { statusId }) => ({
5+
card: state.getIn(['cards', statusId], null),
6+
});
7+
8+
export default connect(mapStateToProps)(Card);

app/javascript/mastodon/reducers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import relationships from './relationships';
1414
import settings from './settings';
1515
import push_notifications from './push_notifications';
1616
import status_lists from './status_lists';
17+
import cards from './cards';
1718
import mutes from './mutes';
1819
import reports from './reports';
1920
import contexts from './contexts';
@@ -45,6 +46,7 @@ const reducers = {
4546
relationships,
4647
settings,
4748
push_notifications,
49+
cards,
4850
mutes,
4951
reports,
5052
contexts,

app/javascript/styles/mastodon/components.scss

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,9 +2562,6 @@ a.status-card {
25622562
display: block;
25632563
margin-top: 5px;
25642564
font-size: 13px;
2565-
overflow: hidden;
2566-
text-overflow: ellipsis;
2567-
white-space: nowrap;
25682565
}
25692566

25702567
.status-card__image {
@@ -2589,31 +2586,6 @@ a.status-card {
25892586
}
25902587
}
25912588

2592-
.status-card.compact {
2593-
border-color: lighten($ui-base-color, 4%);
2594-
2595-
&.interactive {
2596-
border: 0;
2597-
}
2598-
2599-
.status-card__content {
2600-
padding: 8px;
2601-
padding-top: 10px;
2602-
}
2603-
2604-
.status-card__title {
2605-
white-space: nowrap;
2606-
}
2607-
2608-
.status-card__image {
2609-
flex: 0 0 60px;
2610-
}
2611-
}
2612-
2613-
a.status-card.compact:hover {
2614-
background-color: lighten($ui-base-color, 4%);
2615-
}
2616-
26172589
.status-card__image-image {
26182590
border-radius: 4px 0 0 4px;
26192591
display: block;

app/models/status.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,13 @@ class Status < ApplicationRecord
9090
:conversation,
9191
:status_stat,
9292
:tags,
93-
:preview_cards,
9493
:stream_entry,
9594
active_mentions: :account,
9695
reblog: [
9796
:account,
9897
:application,
9998
:stream_entry,
10099
:tags,
101-
:preview_cards,
102100
:media_attachments,
103101
:conversation,
104102
:status_stat,
@@ -166,10 +164,6 @@ def target
166164
reblog
167165
end
168166

169-
def preview_card
170-
preview_cards.first
171-
end
172-
173167
def title
174168
if destroyed?
175169
"#{account.acct} deleted status"

app/serializers/rest/status_serializer.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class REST::StatusSerializer < ActiveModel::Serializer
2020
has_many :tags
2121
has_many :emojis, serializer: REST::CustomEmojiSerializer
2222

23-
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
24-
2523
def id
2624
object.id.to_s
2725
end

app/services/fetch_link_card_service.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def process_url
6262

6363
def attach_card
6464
@status.preview_cards << @card
65-
Rails.cache.delete(@status)
6665
end
6766

6867
def parse_urls

0 commit comments

Comments
 (0)