Skip to content

Commit

Permalink
インターネットお絵かきマンの絵だけ見たーい!
Browse files Browse the repository at this point in the history
  • Loading branch information
mohemohe committed Aug 15, 2023
1 parent 398bb6a commit ff1c00a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/javascript/mastodon/components/status_list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class StatusList extends ImmutablePureComponent {
withCounters: PropTypes.bool,
timelineId: PropTypes.string,
lastId: PropTypes.string,
mediaOnly: PropTypes.bool,
};

static defaultProps = {
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/features/list_timeline/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class ListTimeline extends PureComponent {
onLoadMore={this.handleLoadMore}
emptyMessage={<FormattedMessage id='empty_column.list' defaultMessage='There is nothing in this list yet. When members of this list post new statuses, they will appear here.' />}
bindToDocument={!multiColumn}
mediaOnly={title.trim().startsWith("🖼️") && localStorage.plusminus_config_filter_media_only_toots === "enabled"}
/>

<Helmet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class PlusMinusSettingModal extends React.Component {
encode_ame: 'disabled',
komiflo_linkify: 'disabled',
jumbomoji: 'disabled',
filter_media_only_toots: 'disabled',
},
};

Expand Down Expand Up @@ -440,6 +441,19 @@ class PlusMinusSettingModal extends React.Component {
通報をすばやく、簡単に行えるようになります
</p>
</div>
<div style={styles.config}>
<label>
<input
type='checkbox'
checked={this.state.config.filter_media_only_toots === 'enabled'}
onChange={(e) => this.updateConfig('filter_media_only_toots', e.target.checked ? 'enabled' : 'disabled')}
/>
<code>🖼️</code> から始まる名前のリストのトゥートをメディアでフィルタする
</label>
<p style={styles.description}>
名前が <code>🖼️</code> から始まるリストTLの表示対象を、メディアが添付されているものだけに絞り込みます
</p>
</div>

<div style={styles.section}>
<h2>投稿欄</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import StatusList from '../../../components/status_list';
import { me } from '../../../initial_state';

const makeGetStatusIds = (pending = false) => createSelector([
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
(state, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
(state, _, { type }) => state.getIn(['settings', type], ImmutableMap()),
(state, _, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
(state) => state.get('statuses'),
], (columnSettings, statusIds, statuses) => {
(_, props) => props,
], (columnSettings, statusIds, statuses, props) => {
return statusIds.filter(id => {
if (id === null) return true;

Expand All @@ -29,6 +30,14 @@ const makeGetStatusIds = (pending = false) => createSelector([
showStatus = showStatus && (statusForId.get('in_reply_to_id') === null || statusForId.get('in_reply_to_account_id') === me);
}

if (props.mediaOnly === true) {
if (statusForId.get('reblog')) {
showStatus = showStatus && statuses.get(statusForId.get('reblog')).get('media_attachments')?.size > 0;
} else {
showStatus = showStatus && statusForId.get('media_attachments')?.size > 0;
}
}

return showStatus;
});
});
Expand All @@ -37,13 +46,13 @@ const makeMapStateToProps = () => {
const getStatusIds = makeGetStatusIds();
const getPendingStatusIds = makeGetStatusIds(true);

const mapStateToProps = (state, { timelineId }) => ({
statusIds: getStatusIds(state, { type: timelineId }),
lastId: state.getIn(['timelines', timelineId, 'items'])?.last(),
isLoading: state.getIn(['timelines', timelineId, 'isLoading'], true),
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
hasMore: state.getIn(['timelines', timelineId, 'hasMore']),
numPending: getPendingStatusIds(state, { type: timelineId }).size,
const mapStateToProps = (state, props) => ({
statusIds: getStatusIds(state, props, { type: props.timelineId }),
lastId: state.getIn(['timelines', props.timelineId, 'items'])?.last(),
isLoading: state.getIn(['timelines', props.timelineId, 'isLoading'], true),
isPartial: state.getIn(['timelines', props.timelineId, 'isPartial'], false),
hasMore: state.getIn(['timelines', props.timelineId, 'hasMore']),
numPending: getPendingStatusIds(state, props, { type: props.timelineId }).size,
});

return mapStateToProps;
Expand Down

0 comments on commit ff1c00a

Please sign in to comment.