1
0

Merge branch 'pr2462'

This commit is contained in:
Noa Himesaka 2024-01-19 18:40:53 +09:00
commit 006ea5ea5e
17 changed files with 52 additions and 65 deletions

View File

@ -8,6 +8,7 @@ import { withRouter } from 'react-router-dom';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import AddReactionIcon from '@/material-icons/400-24px/add_reaction.svg?react';
import BookmarkIcon from '@/material-icons/400-24px/bookmark-fill.svg?react';
import BookmarkBorderIcon from '@/material-icons/400-24px/bookmark.svg?react';
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
@ -338,7 +339,8 @@ class StatusActionBar extends ImmutablePureComponent {
onClick={this.handleNoOp} // EmojiPickerDropdown handles that
title={intl.formatMessage(messages.react)}
disabled={!canReact}
icon='plus'
icon='add_reaction'
iconComponent={AddReactionIcon}
/>
);

View File

@ -6,6 +6,7 @@ import { FormattedMessage } from 'react-intl';
import ImmutablePropTypes from 'react-immutable-proptypes';
import AddReactionIcon from '@/material-icons/400-24px/add_reaction.svg?react';
import EditIcon from '@/material-icons/400-24px/edit.svg?react';
import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react';
import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
@ -130,7 +131,8 @@ export default class StatusPrepend extends PureComponent {
iconComponent = StarIcon;
break;
case 'reaction':
iconId = 'plus';
iconId = 'add_reaction';
iconComponent = AddReactionIcon;
break;
case 'featured':
iconId = 'thumb-tack';

View File

@ -96,11 +96,11 @@ class Reaction extends ImmutablePureComponent {
} else {
addReaction(statusId, reaction.get('name'));
}
}
};
handleMouseEnter = () => this.setState({ hovered: true })
handleMouseEnter = () => this.setState({ hovered: true });
handleMouseLeave = () => this.setState({ hovered: false })
handleMouseLeave = () => this.setState({ hovered: false });
render() {
const { reaction } = this.props;

View File

@ -3,6 +3,7 @@ import { PureComponent } from 'react';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import AddReactionIcon from '@/material-icons/400-24px/add_reaction.svg?react';
import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react';
import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
import PersonAddIcon from '@/material-icons/400-24px/person_add.svg?react';
@ -88,7 +89,7 @@ class FilterBar extends PureComponent {
onClick={this.onClick('reaction')}
title={intl.formatMessage(tooltips.reactions)}
>
<Icon id='plus' fixedWidth />
<Icon id='add_reaction' icon={AddReactionIcon} />
</button>
<button
className={selectedFilter === 'reblog' ? 'active' : ''}

View File

@ -8,6 +8,7 @@ import { withRouter } from 'react-router-dom';
import ImmutablePropTypes from 'react-immutable-proptypes';
import AddReactionIcon from '@/material-icons/400-24px/add_reaction.svg?react';
import BookmarkIcon from '@/material-icons/400-24px/bookmark-fill.svg?react';
import BookmarkBorderIcon from '@/material-icons/400-24px/bookmark.svg?react';
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
@ -249,6 +250,18 @@ class ActionBar extends PureComponent {
replyIconComponent = ReplyAllIcon;
}
const canReact = signedIn && status.get('reactions').filter(r => r.get('count') > 0 && r.get('me')).size < maxReactions;
const reactButton = (
<IconButton
className='add-reaction-icon'
onClick={this.handleNoOp} // EmojiPickerDropdown handles that
title={intl.formatMessage(messages.react)}
disabled={!canReact}
icon='add_reaction'
iconComponent={AddReactionIcon}
/>
);
const reblogPrivate = status.getIn(['account', 'id']) === me && status.get('visibility') === 'private';
let reblogTitle, reblogIconComponent;

View File

@ -58,7 +58,6 @@ class DetailedStatus extends ImmutablePureComponent {
onToggleMediaVisibility: PropTypes.func,
onReactionAdd: PropTypes.func.isRequired,
onReactionRemove: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
...WithRouterPropTypes,
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M800-680v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80ZM620-520q25 0 42.5-17.5T680-580q0-25-17.5-42.5T620-640q-25 0-42.5 17.5T560-580q0 25 17.5 42.5T620-520Zm-280 0q25 0 42.5-17.5T400-580q0-25-17.5-42.5T340-640q-25 0-42.5 17.5T280-580q0 25 17.5 42.5T340-520Zm140 260q68 0 123.5-38.5T684-400H276q25 63 80.5 101.5T480-260Zm0 180q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q43 0 83 8.5t77 24.5v167h80v80h142q9 29 13.5 58.5T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z"/></svg>

After

Width:  |  Height:  |  Size: 622 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-480Zm0 400q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q43 0 83 8.5t77 24.5v90q-35-20-75.5-31.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-32-6.5-62T776-600h86q9 29 13.5 58.5T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm320-600v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80ZM620-520q25 0 42.5-17.5T680-580q0-25-17.5-42.5T620-640q-25 0-42.5 17.5T560-580q0 25 17.5 42.5T620-520Zm-280 0q25 0 42.5-17.5T400-580q0-25-17.5-42.5T340-640q-25 0-42.5 17.5T280-580q0 25 17.5 42.5T340-520Zm140 260q68 0 123.5-38.5T684-400H276q25 63 80.5 101.5T480-260Z"/></svg>

After

Width:  |  Height:  |  Size: 744 B

View File

@ -5,7 +5,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
original_status = status_from_uri(object_uri)
return if original_status.nil? || !original_status.account.local? || delete_arrived_first?(@json['id'])
return if maybe_process_misskey_reaction
return if maybe_process_embedded_reaction
return if @account.favourited?(original_status)
@ -15,11 +15,12 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
Trends.statuses.register(original_status)
end
# Misskey delivers reactions as likes with the emoji in _misskey_reaction
# see https://misskey-hub.net/ns.html#misskey-reaction for details
def maybe_process_misskey_reaction
# Some servers deliver reactions as likes with the emoji in content
# Versions of Misskey before 12.1.0 specify emojis in _misskey_reaction instead, so we check both
# See https://misskey-hub.net/ns.html#misskey-reaction for details
def maybe_process_embedded_reaction
original_status = status_from_uri(object_uri)
name = @json['_misskey_reaction']
name = @json['content'] || @json['_misskey_reaction']
return false if name.nil?
if /^:.*:$/.match?(name)

View File

@ -110,7 +110,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
if @account.favourited?(status)
favourite = status.favourites.where(account: @account).first
favourite&.destroy
elsif @object['_misskey_reaction'].present?
elsif @object['content'].present? || @object['_misskey_reaction'].present?
undo_emoji_react
else
delete_later!(object_uri)

View File

@ -288,7 +288,9 @@ class Status < ApplicationRecord
if account.nil?
scope.select('name, custom_emoji_id, count(*) as count, false as me')
else
# rubocop:disable Layout/LineLength
scope.select("name, custom_emoji_id, count(*) as count, exists(select 1 from status_reactions r where r.account_id = #{account.id} and r.status_id = status_reactions.status_id and r.name = status_reactions.name and (r.custom_emoji_id = status_reactions.custom_emoji_id or r.custom_emoji_id is null and status_reactions.custom_emoji_id is null)) as me")
# rubocop:enable Layout/LineLength
end
end

View File

@ -51,7 +51,7 @@ class InitialStateSerializer < ActiveModel::Serializer
store[:default_content_type] = object_account_user.setting_default_content_type
store[:system_emoji_font] = object_account_user.setting_system_emoji_font
store[:show_trends] = Setting.trends && object_account_user.setting_trends
store[:visible_reactions] = object.current_account.user.setting_visible_reactions
store[:visible_reactions] = object_account_user.setting_visible_reactions
else
store[:auto_play_gif] = Setting.auto_play_gif
store[:display_media] = Setting.display_media

View File

@ -19,7 +19,7 @@ class ReactService < BaseService
Trends.statuses.register(status)
create_notification(reaction)
bump_potential_friendship(account, status)
increment_statistics
reaction
end
@ -36,11 +36,8 @@ class ReactService < BaseService
end
end
def bump_potential_friendship(account, status)
def increment_statistics
ActivityTracker.increment('activity:interactions')
return if account.following?(status.account_id)
PotentialFriendshipTracker.record(account.id, status.account_id, :reaction)
end
def build_json(reaction)

View File

@ -1,45 +1,13 @@
%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.email-body
.email-container
%table.content-section{ cellspacing: 0, cellpadding: 0 }
%tbody
= content_for :heading do
= render 'application/mailer/heading', heading_title: t('notification_mailer.reaction.title'), heading_subtitle: t('notification_mailer.reaction.body', name: @account.pretty_acct), heading_image_url: frontend_asset_url('images/mailer-new/heading/reaction.png')
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-body-padding-td
%table.email-inner-card-table{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-inner-card-td
= render 'status', status: @status, time_zone: @me.user_time_zone
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.content-cell.hero
.email-row
.col-6
%table.column{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.column-cell.text-center.padded
%table.hero-icon{ align: 'center', cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td
= image_tag full_pack_url('media/images/mailer/icon_add.png'), alt: ''
%h1= t 'notification_mailer.reaction.title'
%p.lead= t('notification_mailer.reaction.body', name: @account.pretty_acct)
= render 'status', status: @status, time_zone: @me.user_time_zone
%table.email-table{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.email-body
.email-container
%table.content-section{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.content-cell.content-start.border-top
%table.column{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.column-cell.button-cell
%table.button{ align: 'center', cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.button-primary
= link_to web_url("@#{@status.account.pretty_acct}/#{@status.id}") do
%span= t 'application_mailer.view_status'
%td.email-padding-top-24
= render 'application/mailer/button', text: t('application_mailer.view_status'), url: web_url("@#{@status.account.pretty_acct}/#{@status.id}")

View File

@ -52,7 +52,7 @@
= ff.input :'web.use_system_emoji_font', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_system_emoji_font'), glitch_only: true
.fields-group.fields-row__column.fields-row__column-6
= ff.input :'visible_reactions', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_visible_reactions'), input_html: { type: 'number', min: '0', data: { default: '6' } }, hint: false
= ff.input :visible_reactions, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_visible_reactions'), input_html: { type: 'number', min: '0', data: { default: '6' } }, hint: false
%h4= t 'appearance.discovery'

View File

@ -42,7 +42,7 @@ class MoveEmojiReactionSettings < ActiveRecord::Migration[6.1]
end
end
user.update_column('settings', Oj.dump(user_settings)) # rubocop:disable Rails/SkipsModelValidations
user.update_column('settings', Oj.dump(user_settings))
end
end
end